Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Multiple smtpmail Accounts
@ 2007-11-07 14:32 Volkan YAZICI
  2007-11-07 16:30 ` Exal de Jesus Garcia Carrillo
  2007-11-07 17:05 ` CHENG Gao
  0 siblings, 2 replies; 4+ messages in thread
From: Volkan YAZICI @ 2007-11-07 14:32 UTC (permalink / raw)
  To: info-gnus-english

Hi,

I have different server entries both in my smtpmail-starttls-
credentials and smtpmail-auth-credentials variables. But when I want
to send a mail in gnus, smtpmail always prefers to use the server
defined in smtpmail-smtp-server. In case of I empty this variable,
smtpmail complains that smtpmail-smtp-server is not configured.

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?


Regards.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple smtpmail Accounts
  2007-11-07 14:32 Multiple smtpmail Accounts Volkan YAZICI
@ 2007-11-07 16:30 ` Exal de Jesus Garcia Carrillo
  2007-11-08 19:25   ` Volkan YAZICI
  2007-11-07 17:05 ` CHENG Gao
  1 sibling, 1 reply; 4+ messages in thread
From: Exal de Jesus Garcia Carrillo @ 2007-11-07 16:30 UTC (permalink / raw)
  To: info-gnus-english

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, 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 


search from change smtp server

-- 
Spam protection: 
In my e-mail remplace the words `no-spam' with `exal'.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple smtpmail Accounts
  2007-11-07 14:32 Multiple smtpmail Accounts Volkan YAZICI
  2007-11-07 16:30 ` Exal de Jesus Garcia Carrillo
@ 2007-11-07 17:05 ` CHENG Gao
  1 sibling, 0 replies; 4+ messages in thread
From: CHENG Gao @ 2007-11-07 17:05 UTC (permalink / raw)
  To: info-gnus-english

*On Wed, 07 Nov 2007 06:32:37 -0800
* Also sprach Volkan YAZICI <volkan.yazici@gmail.com>:

> Hi,
>
> I have different server entries both in my smtpmail-starttls-
> credentials and smtpmail-auth-credentials variables. But when I want to
> send a mail in gnus, smtpmail always prefers to use the server defined
> in smtpmail-smtp-server. In case of I empty this variable, smtpmail
> complains that smtpmail-smtp-server is not configured.
>
> 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?
>
>
> Regards.
Using smtpmail.el seems not an easy solution. I use a lightweight
standalone application named MSMTP (http://msmtp.sf.net) and wrote a
simple function (put in .gnus.el) to choose among 7 email accounts. You
can change your from address at any time before sending. If you are
interested you can read my addtion to EmacsWiki page -
http://www.emacswiki.org/cgi-bin/wiki/GnusMSMTP

My addtion is at the bottom under title "Yet Another Gnus/MSMTP Setting
for Easy Multi-SMTP Sending".

-- 
Numquam minus solus quam cum solus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Multiple smtpmail Accounts
  2007-11-07 16:30 ` Exal de Jesus Garcia Carrillo
@ 2007-11-08 19:25   ` Volkan YAZICI
  0 siblings, 0 replies; 4+ messages in thread
From: Volkan YAZICI @ 2007-11-08 19:25 UTC (permalink / raw)
  To: info-gnus-english

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-11-08 19:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-07 14:32 Multiple smtpmail Accounts Volkan YAZICI
2007-11-07 16:30 ` Exal de Jesus Garcia Carrillo
2007-11-08 19:25   ` Volkan YAZICI
2007-11-07 17:05 ` CHENG Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).