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: Wed, 17 Aug 2011 11:54:01 +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> <87ippzf7jx.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 1313546053 4154 80.91.229.12 (17 Aug 2011 01:54:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 17 Aug 2011 01:54:13 +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 Wed Aug 17 03:54:09 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 1QtVKZ-0002XX-PN for ged-emacs-devel@m.gmane.org; Wed, 17 Aug 2011 03:54:08 +0200 Original-Received: from localhost ([::1]:38243 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtVKZ-0000qz-B7 for ged-emacs-devel@m.gmane.org; Tue, 16 Aug 2011 21:54:07 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:44233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtVKW-0000qk-IO for emacs-devel@gnu.org; Tue, 16 Aug 2011 21:54:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QtVKV-0003Lm-1v for emacs-devel@gnu.org; Tue, 16 Aug 2011 21:54:04 -0400 Original-Received: from mail-iy0-f175.google.com ([209.85.210.175]:56612) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtVKU-0003Lc-TW for emacs-devel@gnu.org; Tue, 16 Aug 2011 21:54:03 -0400 Original-Received: by iyn15 with SMTP id 15so747465iyn.6 for ; Tue, 16 Aug 2011 18:54:01 -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=S5kHp9W4shsJF6SpnKUeghTr+UqgYKmSiveeUkJkR6o=; b=nCng2oiDlNqYklokAFYnemf4tzGwLLGOhOc/9SKb4Nui0sA/wAWRdKW5WokIgAEtQ2 IXw3IY6Jaj0o2ZqDzLYPbBYavblK524ONUjMlYQ5Mm235HrSEyhyHK8DZeWApFeFZVrH jG9l5Ryw9n9XtY66xGBl4HsE1bSUgomoOjQjQ= Original-Received: by 10.231.83.140 with SMTP id f12mr840697ibl.64.1313546041648; Tue, 16 Aug 2011 18:54:01 -0700 (PDT) Original-Received: by 10.231.43.137 with HTTP; Tue, 16 Aug 2011 18:54:01 -0700 (PDT) In-Reply-To: <87ippzf7jx.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:143343 Archived-At: On Mon, Aug 15, 2011 at 5:38 PM, Vijay Lakshminarayanan wrote: > 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'. =A0Searc= h >>>> 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, wo= uld >>>> be to pay attention to ~/.authinfo when it is present, but fall back t= o >>>> 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.]*\\)@" f= rom) >>> =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. =A0S= o credentials >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0;; for both addresses are stored under t= he 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-crede= ntials*)))) >>> =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, someo= ne >>> could possibly get my email account information by convincing me to >>> download their cool emacs package. =A0But I don't think I'm that import= ant :-) >>> >>> 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 =A0knowing 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. =A0I have not linked my accounts with each other this way > and I don't want to. > >> thanks, >> >> Tim > > -- > Cheers > ~vijay > > Gnus should be more complicated. > OK, thanks Jijay. So, it would seem the use case is possibly something specific google has done to detect possible abuse of an email account. I've not run into this myself, but at least this gives one possible data point on why this additional complexity may be required. Tim