First you have to set gnus as mail handler.
(setq mail-user-agent 'gnus-user-agent)
Still this doesn't work, if gnus is not running when starting to write a mail with C-x m. Here a advice helps.
(defadvice gnus-msg-mail (before start-gnus activate)
(require 'gnus-start)
(unless (gnus-alive-p)
(save-window-excursion
(let ((inhibit-redisplay t))
(gnus)))))