Gnus development mailing list
 help / color / mirror / Atom feed
From: Richard Riley <rileyrg@googlemail.com>
To: ding@gnus.org
Subject: Re: Multiple SMTP servers with Gnus?
Date: Mon, 14 Feb 2011 12:26:26 +0100	[thread overview]
Message-ID: <ytd3mukgbh.fsf@news.eternal-september.org> (raw)
In-Reply-To: <m2mxlzar5w.fsf@randomsample.de> (David Engster's message of "Mon, 14 Feb 2011 10:42:19 +0100")

David Engster <deng@randomsample.de> writes:

> Lars Ingebrigtsen writes:
>> Bruno Tavernier <tavernier.bruno@gmail.com> writes:
>>
>>> I wrote this simple piece of elisp code to automatically choose the smtp
>>> parameters depending on the content (regexp) in the From header.
>>
>> [...]
>>
>>>    ((string-match "gmail" (message-field-value "From"))
>>>     ; SMTP address and port
>>>     (setq smtpmail-smtp-server "smtp.gmail.com")
>>
>> This seems nice...  but why would one use different outgoing SMTP
>> servers?  
>
> Thanks to SPF [1], not using the correct SMTP server for your address
> can easily result in your mails getting rejected or scored up by
> spamassassin.
>
> To be on topic: my solution is here
>
> http://www.randomsample.de/dru5/node/63
>
> -David
>
> [1] http://en.wikipedia.org/wiki/Sender_Policy_Framework
>

Yet Another Version (!) of the same thing here is here which takes into
account the validation method used.

http://www.emacswiki.org/emacs/MultipleSMTPAccounts

It would be nice if a "gnus posting style"/"use the from address" method
to use multiple smtp accounts was standard in gnus - google land is
littered with copy/pasted versions of the same some which work some
which dont. Possibly it is in Ted's new stuff. Its oft
requested. Especially since gmail smtp (commonly used) wont let you post
using arbitrary from addresses from the same smtp login and more and
more dynamic IPs are blacklisted as spam making posting from your local
lan a touch and go affair.

Another issue is SPF record checking. This code below (again copied from
another version of the link above) sets the user-mail-address in the
gnus posting styles in order to change the envelope to a domain with a
valid spf record : despite having my own domains I still use gmail - let
them worry about backups etc ;)

I find this set up the best as when the code is in place all you need to
do is add to the smtp-accounts, gnus-posting-styles and the
.authinfo.gpg. Why "address" is used on the linked code above I am not
sure. This below uses the "from" and only the "from" what I
understand. This version was posted by Philip and I include it here for
completeness with my slight modifications..

,----
| (defun set-smtp (mech server port user password)
|   "Set related SMTP variables for supplied parameters."
|   (setq smtpmail-smtp-server server
|         smtpmail-smtp-service port
|         smtpmail-auth-credentials (list (list server port user password))
|         smtpmail-auth-supported (list mech)
|         smtpmail-starttls-credentials nil)
|   (message "Setting SMTP server to `%s:%s' for user `%s'."
|            server port user))
| 
| (defun set-smtp-ssl (server port user password &optional key cert)
|   "Set related SMTP and SSL variables for supplied parameters."
|   (setq starttls-use-gnutls t
|         starttls-gnutls-program "gnutls-cli"
|         ;; TODO: Add this to the server parameters
|         ;; starttls-extra-arguments nil
|         smtpmail-smtp-server server
|         smtpmail-smtp-service port
|         smtpmail-auth-credentials (list (list server port user password))
|         smtpmail-starttls-credentials (list (list 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."
|   (interactive)
|   (save-excursion
|     (loop with from = (save-restriction
|                         (message-narrow-to-headers)
|                         (message-fetch-field "from"))
|           for (auth-mech address . auth-spec) in smtp-accounts
|           when (string-match address from)
|           do (cond
|               ((memq auth-mech '(cram-md5 plain login))
|                (return (apply 'set-smtp (cons auth-mech auth-spec))))
|               ((eql auth-mech 'ssl)
|                (return (apply 'set-smtp-ssl auth-spec)))
|               (t (error "Unrecognized SMTP auth. mechanism: `%s'." auth-mech)))
|           finally (error "Cannot infer SMTP information."))))
| 
| (add-hook 'message-send-hook 'change-smtp)
| 
| (setq smtp-accounts '(
|                       (ssl "riley" "smtp.gmail.com" "587"
|                            "rileyrg@gmail.com" nil)
|                       (ssl "shamrock" "smtp.gmail.com" "587"
|                            "shamrockirishbar@gmail.com" nil)))
| 
| (setq gnus-posting-styles `((".*"
| 			     (from "Richard Riley <rileyrg@googlemail.com>")
| 			     (eval(setq gnushush-user-agent-header (quote real)))
| 			     (signature-file "~/.emacs.d/.sigs/rgr.sig")
| 			     (eval (setq mml2015-signers '("********")))
| 			     (eval (setq user-mail-address "rgr@richardriley.net"))
| 			     (organization "aich tea tea pea dicky riley dot net"))))
|      
| (add-to-list `gnus-posting-styles `(,(rx(or "shamrock"))
| 				    (from  "The Shamrock Irish Bar<shamrockirishbar@gmail.com>")
| 				    (eval (setq user-mail-address "shamrock@shamrockirishbar.com"))
| 				    (eval (setq mml2015-signers '("********")))
| 				    (organization "http://www.shamrockirishbar.com")
| 				    (signature-file "~/.emacs.d/.sigs/s.sig")) t)
`----


r.



  reply	other threads:[~2011-02-14 11:26 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-09 17:39 Robert Pluim
2011-02-09 17:46 ` Richard Riley
2011-02-09 18:06   ` Wes Hardaker
2011-02-09 18:48     ` Richard Riley
2011-02-09 22:23       ` Wes Hardaker
2011-02-09 23:27         ` Richard Riley
2011-02-09 20:17 ` Bruno Tavernier
2011-02-11 21:28   ` Robert Pluim
2011-02-14  2:25   ` Lars Ingebrigtsen
2011-02-14  7:45     ` David Edmondson
2011-02-14  8:34       ` Robert Pluim
2011-02-14  9:42     ` David Engster
2011-02-14 11:26       ` Richard Riley [this message]
2011-02-14 20:09         ` Lars Ingebrigtsen
2011-02-14 20:13           ` Lars Ingebrigtsen
2011-02-14 21:08             ` Ted Zlatanov
2011-02-14 21:23               ` Lars Ingebrigtsen
2011-02-16 16:12         ` Johnny
2011-02-16 16:28           ` Ted Zlatanov
2011-02-16 16:45             ` Johnny
2011-02-16 19:06               ` Ted Zlatanov
2011-02-16 20:41                 ` Johnny
2011-02-16 23:17                 ` Leo
2011-02-17 17:04                   ` Ted Zlatanov
2011-02-17 20:33                     ` Broken split-fancy upon updating gnus (Re: Multiple SMTP servers with Gnus?) Johnny
2011-02-17 22:38                       ` Lars Ingebrigtsen
2011-02-18 20:27                       ` Ted Zlatanov
2011-02-18 23:09                         ` Lars Ingebrigtsen
2011-02-21 20:25                           ` Ted Zlatanov
2011-02-19 10:54                         ` Johnny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ytd3mukgbh.fsf@news.eternal-september.org \
    --to=rileyrg@googlemail.com \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).