From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/9870 Path: news.gmane.org!not-for-mail From: Volkan YAZICI Newsgroups: gmane.emacs.gnus.user Subject: Re: Multiple smtpmail Accounts Date: 8 Nov 2007 11:25:56 -0800 Organization: http://groups.google.com Message-ID: <1194525584.114989.13840@e9g2000prf.googlegroups.com> References: <1194445957.392484.29740@o3g2000hsb.googlegroups.com> <87ir4evx0t.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: ger.gmane.org 1194550872 7046 80.91.229.12 (8 Nov 2007 19:41:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 Nov 2007 19:41:12 +0000 (UTC) To: info-gnus-english@gnu.org Original-X-From: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Thu Nov 08 20:41:12 2007 Return-path: Envelope-to: gegu-info-gnus-english@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IqDFQ-0005zg-3c for gegu-info-gnus-english@m.gmane.org; Thu, 08 Nov 2007 20:41:04 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IqDFE-00058K-U6 for gegu-info-gnus-english@m.gmane.org; Thu, 08 Nov 2007 14:40:52 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!e9g2000prf.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.gnus Original-Lines: 74 Original-NNTP-Posting-Host: 88.235.92.163 Original-X-Trace: posting.google.com 1194549971 379 127.0.0.1 (8 Nov 2007 19:26:11 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 8 Nov 2007 19:26:11 +0000 (UTC) In-Reply-To: <87ir4evx0t.fsf@gnu.org> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.8) Gecko/20071004 Iceweasel/2.0.0.8 (Debian-2.0.0.8-1),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: e9g2000prf.googlegroups.com; posting-host=88.235.92.163; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Original-Xref: shelby.stanford.edu gnu.emacs.gnus:80079 X-BeenThere: info-gnus-english@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader \(in English\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Errors-To: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.gnus.user:9870 Archived-At: On Nov 7, 6:30 pm, Exal de Jesus Garcia Carrillo 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.