[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Multiple smtpmail Accounts
From: |
Volkan YAZICI |
Subject: |
Re: Multiple smtpmail Accounts |
Date: |
8 Nov 2007 11:25:56 -0800 |
User-agent: |
G2/1.0 |
On Nov 7, 6:30 pm, Exal de Jesus Garcia Carrillo <no-s...@gnu.org>
wrote:
> Volkan YAZICI em gnu.emacs.gnus escreveu :
> > How can I make smtpmail to select between different servers defined in
> > smtpmail-starttls-credentials and smtpmail-auth-credentials by looking
> > at "From:" header of the about to be sent post?
>
> IIRC, many times was posted something similar
Sorry, I searched the archives but couldn't find anything related. I
should have missed something.
> I use a function (take it from some place, IIRC from Tassilo)
> for this, these is in some place in my .emacs file
>
> http://exal.nipl.net/.emacs
Thanks for the pointer. I have modified the code a little bit, and
here is the solution I use:
(setq
send-mail-function 'smtpmail-send-it
message-send-mail-function 'smtpmail-send-it
mail-from-style nil
user-full-name "Johnny B. Good"
smtpmail-debug-info t
smtpmail-debug-verb t)
(defun set-smtp (server port user password)
"Set related SMTP variables for supplied parameters."
(setq smtpmail-smtp-server server
smtpmail-smtp-service port
smtpmail-auth-crendentials `((,server ,port ,user ,password)))
(message "Setting SMTP server to `%s:%s' for user `%s'."
server port user))
(defun set-smtp-with-ssl (server port user password key cert)
"Set related SMTP and SSL variables for supplied parameters."
(setq starttls-use-gnutls t
starttls-gnutls-program "gnutls-cli"
starttls-extra-arguments nil
smtpmail-smtp-server server
smtpmail-smtp-service port
smtpmail-auth-credentials `((,server ,port ,user ,password))
smtpmail-starttls-credentials `((,server ,port ,key ,cert)))
(message
"Setting SMTP server to `%s:%s' for user `%s'. (SSL enabled.)"
server port user))
(defun change-smtp ()
"Change the SMTP server according to the current from line."
(save-excursion
(let ((from
(save-restriction
(message-narrow-to-headers)
(message-fetch-field "from"))))
(cond
((string-match "me@foo.com" from)
(set-smtp "smtp.foo.com" 25 "me" nil))
((string-match "me@bar.com" from)
(set-smtp-with-ssl
"smtp.bar.com" 587 "me@bar.com" nil nil nil))
(t (error "Cannot interfere SMTP information."))))))
Implementing change-smtp in a more user-friendly fashion is left as an
exercise for the reader. And some more configuration for Gnus:
(setq gnus-posting-styles
'((".*" (address "me@foo.com"))
("bar" (address "me@bar.com")))
Regards.