From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/76699 Path: news.gmane.org!not-for-mail From: Richard Riley Newsgroups: gmane.emacs.gnus.general Subject: Re: Multiple SMTP servers with Gnus? Date: Mon, 14 Feb 2011 12:26:26 +0100 Organization: aich tea tea pea dicky riley dot net Message-ID: References: <87k4h99d3l.fsf@gmail.com> <878vxjic8e.fsf@gnus.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1297682836 10316 80.91.229.12 (14 Feb 2011 11:27:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 14 Feb 2011 11:27:16 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M25042@lists.math.uh.edu Mon Feb 14 12:27:12 2011 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PowaE-0006lj-Vq for ding-account@gmane.org; Mon, 14 Feb 2011 12:27:11 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1PowZt-0000MA-OL; Mon, 14 Feb 2011 05:26:49 -0600 Original-Received: from mx1.math.uh.edu ([129.7.128.32]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1PowZr-0000Lu-Vl for ding@lists.math.uh.edu; Mon, 14 Feb 2011 05:26:47 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1PowZp-0005ds-VY for ding@lists.math.uh.edu; Mon, 14 Feb 2011 05:26:47 -0600 Original-Received: from [85.183.18.158] (helo=asus1015pem) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1PowZo-0008Vt-RZ for ding@gnus.org; Mon, 14 Feb 2011 12:26:45 +0100 Original-Received: from shamrock by asus1015pem with local (Exim 4.72) (envelope-from ) id 1PowZn-0001KH-S9 for ding@gnus.org; Mon, 14 Feb 2011 12:26:43 +0100 In-Reply-To: (David Engster's message of "Mon, 14 Feb 2011 10:42:19 +0100") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) X-Spam-Score: 1.7 (+) X-Spam-Report: SpamAssassin (3.3.1 2010-03-16) analysis follows Bayesian score: 0.0000 Ham tokens: 0.000-1671--4080h-0s--0d--H*u:Emacs, 0.000-1607--3922h-0s--0d--H*u:Gnus, 0.000-1552--3789h-0s--0d--H*u:linux, 0.000-1552--3789h-0s--0d--H*UA:linux, 0.000-1495--3650h-0s--0d--H*u:gnu Spam tokens: 0.987-1--0h-1s--1d--ssig, 0.938-1831--1052h-35624s--0d--H*r:quimby.gnus.org, 0.911-424--488h-11270s--0d--commonly Autolearn status: no 0.0 FSL_HELO_NON_FQDN_1 FSL_HELO_NON_FQDN_1 0.0 FREEMAIL_FROM Sender email is freemail (rileyrg[at]googlemail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.8 RDNS_NONE Delivered to internal network by a host with no rDNS 0.0 HELO_NO_DOMAIN Relay reports its domain incorrectly 1.9 FREEMAIL_REPLY From and body contain different freemails 0.9 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list 0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:76699 Archived-At: David Engster writes: > Lars Ingebrigtsen writes: >> Bruno Tavernier 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 ") | (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") | (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.