Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There used to be a bunch of hacks for using multiple SMTP servers with Gnus that mostly entailed to add a special mail header depending on the current group and parsing this information out with a custom send-mail function.

Since Emacs 24 most available work-arounds broke, while sendmail is now much easier to use and setup with a single server.

What is the best way to have multiple SMTP servers with Gnus and use the one belonging to the group I'm currently reading in Emacs 24?

share|improve this question

I'm using msmtp and this setup and some gnus-posting-styles successfully on Emacs 24.1.1.

(defun cg-feed-msmtp ()
  (if (message-mail-p)
    (let* ((from
          (message-fetch-field "from")))
         ;; I use email address as account label in ~/.msmtprc
         ((string-match "" from) "example1")
         ;; Add more string-match lines for your email accounts
         ((string-match "" from) "example2"))))
      (setq message-sendmail-extra-arguments (list '"-a" account))))))

(setq message-sendmail-envelope-from 'header)
(add-hook 'message-send-mail-hook 'cg-feed-msmtp)

(setq gnus-posting-styles
     (address ""))))
share|improve this answer
I arrived at something incredibly similar a few days ago. – pmr Aug 29 '12 at 23:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.