From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Vijay Lakshminarayanan Newsgroups: gmane.emacs.devel Subject: Re: more on starttls, gnutls-cli and using tls for mail Date: Mon, 15 Aug 2011 13:08:42 +0530 Message-ID: <87ippzf7jx.fsf@gmail.com> 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 1313393938 20395 80.91.229.12 (15 Aug 2011 07:38:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 15 Aug 2011 07:38:58 +0000 (UTC) Cc: Karl Fogel , Leo , emacs-devel@gnu.org To: Tim Cross Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 15 09:38:54 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 1Qsrl7-0000Nu-GW for ged-emacs-devel@m.gmane.org; Mon, 15 Aug 2011 09:38:53 +0200 Original-Received: from localhost ([::1]:39981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qsrl6-00045W-NX for ged-emacs-devel@m.gmane.org; Mon, 15 Aug 2011 03:38:52 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:46645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qsrl3-00045R-T2 for emacs-devel@gnu.org; Mon, 15 Aug 2011 03:38:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qsrl2-0004nW-AQ for emacs-devel@gnu.org; Mon, 15 Aug 2011 03:38:49 -0400 Original-Received: from mail-pz0-f44.google.com ([209.85.210.44]:41350) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qsrl2-0004nR-1C for emacs-devel@gnu.org; Mon, 15 Aug 2011 03:38:48 -0400 Original-Received: by pzk36 with SMTP id 36so8185117pzk.17 for ; Mon, 15 Aug 2011 00:38:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=cBGXgLzDvbp62MXeNCXa2T83kVnBy/CX6zSEgWsNodc=; b=fkNfwvV10lMAsZM6amNHt08wmzg8LGEoRH3tecGGUW4nmJYgjZBuPp/TFICTq8rSEZ HOH49MdOoJxpuqWN/mdCGlDTrnxOF58uvPSPrkP+EICznIXxuUieSMiAnM9ozEFCRzNc yZchGavcaEaWxyyRp3opm8HGcakpXTelpZVK4= Original-Received: by 10.143.24.23 with SMTP id b23mr1741317wfj.136.1313393926930; Mon, 15 Aug 2011 00:38:46 -0700 (PDT) Original-Received: from BALROG ([59.92.34.150]) by mx.google.com with ESMTPS id s9sm3484962pbk.50.2011.08.15.00.38.43 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Aug 2011 00:38:46 -0700 (PDT) In-Reply-To: (Tim Cross's message of "Mon, 15 Aug 2011 16:03:57 +1000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (windows-nt) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.44 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:143222 Archived-At: Tim Cross writes: > 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, wou= ld >>> 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.]*\\)@" fr= om) >> =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@= gmail.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 th= e 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-creden= tials*)))) >> =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 importa= nt :-) >> >> 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. Originally, I used your technique too but recently I got a warning on one of my gmail accounts regarding "suspicious activity on the account" and had to change my password, receive an authentication code to my phone to confirm the account etc., after which I switched to my hook. Now, I don't know if changing the from address while being authenticated to another /caused/ the issue but I haven't faced this issue after switching to my current scheme which, admittedly complicated, isn't so hard either. On the browser, gmail allows you to explicitly change your from address when replying but it first requires confirmation that you control the other address. I have not linked my accounts with each other this way and I don't want to. > thanks, > > Tim --=20 Cheers ~vijay Gnus should be more complicated.