On Nov 7, 6:30 pm, Exal de Jesus Garcia Carrillo <[EMAIL PROTECTED]>
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 "[EMAIL PROTECTED]" from)
        (set-smtp "smtp.foo.com" 25 "me" nil))
       ((string-match "[EMAIL PROTECTED]" from)
        (set-smtp-with-ssl
         "smtp.bar.com" 587 "[EMAIL PROTECTED]" 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 "[EMAIL PROTECTED]"))
        ("bar" (address "[EMAIL PROTECTED]")))


Regards.

_______________________________________________
info-gnus-english mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/info-gnus-english

Reply via email to