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: Sun, 14 Aug 2011 17:32:39 +0530 Message-ID: <87fwl4nqu8.fsf@gmail.com> References: <20039.8838.116211.694328@gargle.gargle.HOWL> <8762m0n5qi.fsf@red-bean.com> <87ipq0k0q0.fsf@red-bean.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1313323391 28835 80.91.229.12 (14 Aug 2011 12:03:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 14 Aug 2011 12:03:11 +0000 (UTC) Cc: Leo , emacs-devel@gnu.org To: Karl Fogel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Aug 14 14:03:06 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 1QsZPF-0008El-Uz for ged-emacs-devel@m.gmane.org; Sun, 14 Aug 2011 14:03:06 +0200 Original-Received: from localhost ([::1]:41493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsZPE-0005bp-Md for ged-emacs-devel@m.gmane.org; Sun, 14 Aug 2011 08:03:04 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:38163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsZP7-0005al-Op for emacs-devel@gnu.org; Sun, 14 Aug 2011 08:03:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QsZP5-0007jA-J0 for emacs-devel@gnu.org; Sun, 14 Aug 2011 08:02:57 -0400 Original-Received: from mail-pz0-f44.google.com ([209.85.210.44]:57346) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsZP5-0007hr-CB for emacs-devel@gnu.org; Sun, 14 Aug 2011 08:02:55 -0400 Original-Received: by pzk36 with SMTP id 36so7164170pzk.17 for ; Sun, 14 Aug 2011 05:02:53 -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; bh=nL2L2Uhn6BVakVINMazXmoDJNx46o6NUfFadr+2z0jg=; b=swy3ltCjmeDQm24SU3KtWRhaHfgnWOvNdPiQUEfsIctcFmPYNauurc7MnC0ju7tASn 1Y9KQzFkAj0XXP7vmUhQsuW58zNVUURdqzcJOwZbFwCmWZ3rLbMTA1De6ClGI1FM1eA0 IA5uCCm1uVPJ67GaaUppAQTBon/NhWn3cr1Zw= Original-Received: by 10.142.117.13 with SMTP id p13mr871324wfc.286.1313323372817; Sun, 14 Aug 2011 05:02:52 -0700 (PDT) Original-Received: from BALROG ([59.92.39.230]) by mx.google.com with ESMTPS id g4sm3062718pbj.25.2011.08.14.05.02.49 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 14 Aug 2011 05:02:51 -0700 (PDT) In-Reply-To: <87ipq0k0q0.fsf@red-bean.com> (Karl Fogel's message of "Sun, 14 Aug 2011 01:42:47 -0400") 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:143209 Archived-At: 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'. Search > 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! The ideal behavior, I think, would > 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 () "Change the SMTP server according to the current from line." (save-excursion (let* ((username-fn (lambda (from) (when (string-match "\\<\\([A-Za-z.]*\\)@" from) (setq from (match-string 1 from)) ;; Gmail addresses can have dots in them, so sending ;; an email to abcd@gmail.com or a.b.c.d@gmail.com ;; will go to the same destination. So credentials ;; for both addresses are stored under the symbol ;; `abcd'. (setq from (replace-regexp-in-string "\\." "" from)) (intern from)))) (from (save-restriction (message-narrow-to-headers) (message-fetch-field "from"))) (username (funcall username-fn from)) (credentials (cdr (assoc username *gmail-auth-credentials*)))) (if credentials (setq smtpmail-starttls-credentials credentials smtpmail-auth-credentials credentials) (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" "password1")) (account2 ("smtp.gmail.com" 587 "account2@gmail.com" "password2")) (account3 ("smtp.gmail.com" 587 "account3@gmail.com" "password3")) (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 (load "~/.gmails.gpg")) Takes care of authentication. Of course, now that this is out, someone could possibly get my email account information by convincing me to download their cool emacs package. But I don't think I'm that important :-) Hope this code helps someone. As with other Free Software licenses, this comes with NO WARRANTY. > -Karl > > [1] http://svn.red-bean.com/repos/kfogel/trunk/.emacs > -- Cheers ~vijay Gnus should be more complicated.