From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/79573 Path: news.gmane.org!not-for-mail From: Johnny Newsgroups: gmane.emacs.gnus.general Subject: Re: Multiple gmail accounts and SMTP (again) Date: Mon, 25 Jul 2011 21:23:45 +0100 Message-ID: <87ipqq85ym.fsf@DeuxExMachina.config> References: <87r55fqtyv.fsf@DeuxExMachina.config> <82livmutrm.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1311625658 31299 80.91.229.12 (25 Jul 2011 20:27:38 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 25 Jul 2011 20:27:38 +0000 (UTC) Cc: ding@gnus.org To: Sivaram Neelakantan Original-X-From: ding-owner+M27869@lists.math.uh.edu Mon Jul 25 22:27:33 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 1QlRkT-0004w2-4a for ding-account@gmane.org; Mon, 25 Jul 2011 22:27:33 +0200 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 1QlRkE-0003kS-MF; Mon, 25 Jul 2011 15:27:18 -0500 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 1QlRkD-0003kB-6n for ding@lists.math.uh.edu; Mon, 25 Jul 2011 15:27:17 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx1.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1QlRkB-0001dW-8O for ding@lists.math.uh.edu; Mon, 25 Jul 2011 15:27:17 -0500 Original-Received: from mailout-eu.gmx.com ([213.165.64.42]) by quimby.gnus.org with smtp (Exim 4.72) (envelope-from ) id 1QlRk9-0002YI-EI for ding@gnus.org; Mon, 25 Jul 2011 22:27:13 +0200 Original-Received: (qmail invoked by alias); 25 Jul 2011 20:27:07 -0000 Original-Received: from 78-86-131-176.zone2.bethere.co.uk (EHLO DeuxExMachina.config) [78.86.131.176] by mail.gmx.com (mp-eu001) with SMTP; 25 Jul 2011 22:27:07 +0200 X-Authenticated: #57368918 X-Provags-ID: V01U2FsdGVkX18GUBsEdi4GbECiWmffCVCLJgcZ/ZInL0npvlyHc6 /F4CUTRR7qBzMu In-Reply-To: <82livmutrm.fsf@gmail.com> (Sivaram Neelakantan's message of "Mon, 25 Jul 2011 23:28:37 +0530") User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/23.2 (gnu/linux) X-Y-GMX-Trusted: 0 X-Spam-Score: -1.9 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:79573 Archived-At: Sivaram Neelakantan writes: > On Mon, Jul 25 2011,Johnny wrote: > > > [snipped 28 lines] > >> (For SMTP, I am using the emacs-wiki setup, as described here: >> http://www.emacswiki.org/emacs/MultipleSMTPAccounts) >> >> I then attempted to use virtual server names for SMTP as well, i.e.: >> In .gnus.el: >> (setq smtp-accounts '( >> (ssl "gmail1" "smtp.gmail.com" "587" >> "gmail1@gmail.com" nil) >> (ssl "gmail2" "smtp.gmail.com" "587" >> "gmail2@gmail.com" nil))) And using the cusomtised sendmail parts from http://www.emacswiki.org/emacs/MultipleSMTPAccounts as: ;; Now lets configure smtpmail.el with your name and functions to send ;; mail using your smtp accounts by changing the from field (require 'smtpmail) (setq send-mail-function 'smtpmail-send-it message-send-mail-function 'smtpmail-send-it mail-from-style nil user-full-name "Your name" smtpmail-debug-info t smtpmail-debug-verb t) ;Update only the smtp-accounts, gnus-posting-styles and the .authinfo.gpg (defun set-smtp (mech server port user password) "Set related SMTP variables for supplied parameters." (setq smtpmail-smtp-server server smtpmail-default-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" smtpmail-default-smtp-server server ;; 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.) Key: `%s' Cert: `%s' Pass: `%s'" server port user key cert password)) (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.")))) (defvar %smtpmail-via-smtp (symbol-function 'smtpmail-via-smtp)) (defun smtpmail-via-smtp (recipient smtpmail-text-buffer) (with-current-buffer smtpmail-text-buffer (change-smtp)) (funcall (symbol-value '%smtpmail-via-smtp) recipient smtpmail-text-buffer)) >> >> And in authinfo: >> machine gmail1 login gmail1@gmail.com password gmail1pass port 587 >> machine gmail2 login gmail2@gmail.com password gmail2pass port 587 >> >> This breaks the sendmail/authinfo functionality such that I have to >> enter credentials every time sending mail from either account. >> >> If I instead replace the 2 lines above in authinfo with: >> machine smtp.gmail.com login gmail1@gmail.com password gmail1pass port 587 >> >> This makes mailing from both addresses work. I /think/ the setup makes >> gmail2 use gmail1's SMTP credentials to send the mail (note that I >> didn't have to do any changes in .gnus.el on the gmail2 credentials), >> and indeed, when it is received, the posting-styles for gmail2 is used, >> but the senders mail address has been changed to gmail1, which I do not >> fancy at all. > > Can you post your customised sendmail parts that you took from > http://www.emacswiki.org/emacs/MultipleSMTPAccounts I amended the code as it appears in my .gnus.el above. > > It's possible that smtp-mail-address is not getting correctly picked up? Maybe, but I don't know how to debug. I have hacked away on a copy/paste trial/error basis. Not too academic, but hey, sometimes it works. Alas, not this time... cheers -- Johnny