From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim Cross Newsgroups: gmane.emacs.devel Subject: Re: more on starttls, gnutls-cli and using tls for mail Date: Mon, 15 Aug 2011 16:03:57 +1000 Message-ID: References: <20039.8838.116211.694328@gargle.gargle.HOWL> <8762m0n5qi.fsf@red-bean.com> <87ipq0k0q0.fsf@red-bean.com> <87fwl4nqu8.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1313388251 25071 80.91.229.12 (15 Aug 2011 06:04:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 15 Aug 2011 06:04:11 +0000 (UTC) Cc: Karl Fogel , Leo , emacs-devel@gnu.org To: Vijay Lakshminarayanan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 15 08:04:07 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QsqHO-0005m9-6Q for ged-emacs-devel@m.gmane.org; Mon, 15 Aug 2011 08:04:06 +0200 Original-Received: from localhost ([::1]:42586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsqHN-0006Tg-Ms for ged-emacs-devel@m.gmane.org; Mon, 15 Aug 2011 02:04:05 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:53383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsqHK-0006TS-Ih for emacs-devel@gnu.org; Mon, 15 Aug 2011 02:04:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QsqHI-0006Cw-VR for emacs-devel@gnu.org; Mon, 15 Aug 2011 02:04:02 -0400 Original-Received: from mail-iy0-f175.google.com ([209.85.210.175]:51989) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsqHI-0006Cj-Mq for emacs-devel@gnu.org; Mon, 15 Aug 2011 02:04:00 -0400 Original-Received: by iyn15 with SMTP id 15so5187697iyn.6 for ; Sun, 14 Aug 2011 23:03:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=ozfTLdZAUoqJ2ff9COsk0XOH666jGER4jHwte/3W2Fs=; b=j+RagLhxvMMXyLag/FptYMlIAJLxsUow2EEJ/SPpyhbx69LhsH87WiGqCZOz2L7Upf 5r1jlXJohprluYkrRLBdmsoBLlMrOt2iaiCIBm0+gFlhadngX4GiXlWrGykbl2Jdp6wg POEnOg10TXeO1HD+O+OsriBHF+4ogAnmh6idI= Original-Received: by 10.231.45.204 with SMTP id g12mr4534373ibf.79.1313388239557; Sun, 14 Aug 2011 23:03:59 -0700 (PDT) Original-Received: by 10.231.31.67 with HTTP; Sun, 14 Aug 2011 23:03:57 -0700 (PDT) In-Reply-To: <87fwl4nqu8.fsf@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.175 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:143221 Archived-At: On Sun, Aug 14, 2011 at 10:02 PM, Vijay Lakshminarayanan wrote: > Karl Fogel writes: > >> Leo writes: >>>I use smtpmail-auth-credentials to pass different user names for the >>>gmail smtps I am using. With the new smtpmail.el I haven't found a way >>>to do that. >> >> Yes, I'm in that situation too now -- which is why I think it's so >> unfortunate that `smtpmail-auth-credentials' went away :-(. >> >> I've found a way to do it, using the new smtpmail.el, but it's ugly. >> I have `message-send-hook' set up ~/.authinfo for every mail message, >> and then I remove the file afterwards in `message-sent-hook'. =A0Search >> for "kf-set-up-authinfo" in [1] if you want the code. >> >> Naturally I hope we'll restore the lost functionality to smtpmail.el, so >> this kluge will become unnecessary! =A0The ideal behavior, I think, woul= d >> be to pay attention to ~/.authinfo when it is present, but fall back to >> trying `smtpmail-auth-credentials' when it's not. > > I have multiple GMail accounts and I use a hook to use the correct > authentication depending upon which account I'm using. > > The hook function is > > (defun change-smtp () > =A0"Change the SMTP server according to the current from line." > =A0(save-excursion > =A0 =A0(let* ((username-fn > =A0 =A0 =A0 =A0 =A0 =A0(lambda (from) > =A0 =A0 =A0 =A0 =A0 =A0 =A0(when (string-match "\\<\\([A-Za-z.]*\\)@" fro= m) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(setq from (match-string 1 from)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; Gmail addresses can have dots in them, = so sending > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; an email to abcd@gmail.com or a.b.c.d@g= mail.com > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; will go to the same destination. =A0So = credentials > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; for both addresses are stored under the= symbol > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; `abcd'. > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(setq from (replace-regexp-in-string "\\."= "" from)) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(intern from)))) > =A0 =A0 =A0 =A0 =A0 (from (save-restriction > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message-narrow-to-headers) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message-fetch-field "from"))) > =A0 =A0 =A0 =A0 =A0 (username (funcall username-fn from)) > =A0 =A0 =A0 =A0 =A0 (credentials (cdr (assoc username *gmail-auth-credent= ials*)))) > =A0 =A0 =A0(if credentials > =A0 =A0 =A0 =A0 =A0(setq smtpmail-starttls-credentials credentials > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0smtpmail-auth-credentials credentials) > =A0 =A0 =A0 =A0(error "Could not find auth credentials for %s" from))))) > > (add-hook 'message-send-hook 'change-smtp) > > where the variable *gmail-auth-credentials* maintains all my user > account info as an alist in the form: > > ((account1 ("smtp.gmail.com" 587 "account1@gmail.com" =A0"password1")) > =A0(account2 ("smtp.gmail.com" 587 "account2@gmail.com" =A0"password2")) > =A0(account3 ("smtp.gmail.com" 587 "account3@gmail.com" =A0"password3")) > =A0(account4 ("smtp.gmail.com" 587 "acc.ount4@gmail.com" "password4"))) > > I save it in a file ~/.gmails.gpg and in my .gnus I have > > (eval-when-compile > =A0(load "~/.gmails.gpg")) > > Takes care of authentication. =A0Of course, now that this is out, someone > could possibly get my email account information by convincing me to > download their cool emacs package. =A0But I don't think I'm that importan= t :-) > > Hope this code helps someone. =A0As with other Free Software licenses, > this comes with NO WARRANTY. > >> -Karl >> You might be able to clarify something for me. Your the second person I've come across in as many months who changes smtp server based on the from address. Your process is even more of puzzling and I'd like to understand what the reasons are. For example, if your already authenticated with gmail's smtp server, why re-authenticate with different credentials just to send a message with a different from/return address? As far as Iknow, this is not required and it seems to be adding a lot more complexity for no apparent reason that I am aware of. Is there any technical reason that requires this? I frequently use authenticated smtp, but just auithenticate as one user and send email with from/return addresses of different users with no problems. I'm interested knowing what the use case is for doing this as it seems unnecessary and something which is making things needlessly complicated. If there is a good technical reason to do it, I would like to know so that I can be prepared should I need to modify my setup and because I sometimes assist in maintaining a mail client and like to be familiar with the various use cases. thanks, Tim