Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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)
      (save-excursion
    (let* ((from
        (save-restriction
          (message-narrow-to-headers)
          (message-fetch-field "from")))
           (account
        (cond
         ;; I use email address as account label in ~/.msmtprc
         ((string-match "mitchelh@example1.com" from) "example1")
         ;; Add more string-match lines for your email accounts
         ((string-match "mitchelh@example2.com" 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
      '(("nnimap\\+EXAMPLE2:INBOX"
     (address "mitchelh@example2.com"))))
share|improve this answer
    
I arrived at something incredibly similar a few days ago. –  pmr Aug 29 '12 at 23:47
add comment

Your Answer

 
discard

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.