all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tim Cross <theophilusx@gmail.com>
To: Vijay Lakshminarayanan <laksvij@gmail.com>
Cc: Karl Fogel <kfogel@red-bean.com>, Leo <sdl.web@gmail.com>,
	emacs-devel@gnu.org
Subject: Re: more on starttls, gnutls-cli and using tls for mail
Date: Mon, 15 Aug 2011 16:03:57 +1000	[thread overview]
Message-ID: <CAC=50j8gf=bQyxmMbJSs8DzYw-nHXoH=ew0-d5LBnCWk=YPKSA@mail.gmail.com> (raw)
In-Reply-To: <87fwl4nqu8.fsf@gmail.com>

On Sun, Aug 14, 2011 at 10:02 PM, Vijay Lakshminarayanan
<laksvij@gmail.com> wrote:
> Karl Fogel <kfogel@red-bean.com> writes:
>
>> Leo <sdl.web@gmail.com> 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
>>

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



  parent reply	other threads:[~2011-08-15  6:03 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-14  1:19 more on starttls, gnutls-cli and using tls for mail T. V. Raman
2011-08-14  1:26 ` Karl Fogel
2011-08-14  3:40   ` Leo
2011-08-14  5:42     ` Karl Fogel
2011-08-14 12:02       ` Vijay Lakshminarayanan
2011-08-14 21:07         ` Leo
2011-08-15  3:53           ` Vijay Lakshminarayanan
2011-08-15  4:27             ` Leo
2011-08-15  7:41               ` Vijay Lakshminarayanan
2011-08-15  6:03         ` Tim Cross [this message]
2011-08-15  7:38           ` Vijay Lakshminarayanan
2011-08-17  1:54             ` Tim Cross
2011-08-17 14:28               ` Karl Fogel
2011-08-17 22:48                 ` Tim Cross
2011-08-18  0:33                   ` chad
2011-08-18  3:11                   ` Stephen J. Turnbull
2011-08-17 17:27               ` Vijay Lakshminarayanan
2011-08-15  7:47           ` Richard Riley
2011-08-15  9:21           ` David Engster
2011-08-17  2:03             ` Tim Cross
2011-08-17  7:03               ` David Engster
2011-08-15 16:25           ` Dimitri Fontaine
2011-08-16  9:33             ` Leo
2011-08-16 10:12               ` Dimitri Fontaine
2011-08-17  2:13                 ` Tim Cross
2011-08-17  1:08               ` Richard Riley
2011-08-14  6:24   ` Roland Winkler
2011-08-14  6:32     ` Roland Winkler
2011-08-14 16:23     ` Karl Fogel
2011-08-15 15:21       ` Roland Winkler
2011-08-17  2:09         ` Tim Cross
2011-09-25 13:08       ` Ted Zlatanov
2011-09-25 17:26         ` Karl Fogel
2011-09-26 17:22           ` Ted Zlatanov
2011-09-27 15:28             ` Karl Fogel
2011-08-17 21:06   ` Multiple SMTP accounts with smtpmail.el (was: more on starttls, gnutls-cli and using tls for mail) Lars Magne Ingebrigtsen
2011-08-18  3:19     ` Multiple SMTP accounts with smtpmail.el Leo
2011-08-18 14:20     ` Karl Fogel
2011-08-18 16:41       ` Vijay Lakshminarayanan
2011-08-19 14:42       ` Lars Magne Ingebrigtsen
2011-08-21  2:13         ` Karl Fogel
2011-08-21  4:16           ` Lars Magne Ingebrigtsen
2011-08-22  7:22             ` Glenn Morris
2011-09-25 13:10     ` Ted Zlatanov
2011-09-26 18:06       ` Lars Magne Ingebrigtsen
2011-09-26 19:24         ` Ted Zlatanov
2011-09-25 22:46     ` Rasmus
2011-08-14 17:12 ` more on starttls, gnutls-cli and using tls for mail Chong Yidong
2011-08-17 20:58 ` Lars Magne Ingebrigtsen
  -- strict thread matches above, loose matches on Subject: below --
2011-08-14  2:10 raman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAC=50j8gf=bQyxmMbJSs8DzYw-nHXoH=ew0-d5LBnCWk=YPKSA@mail.gmail.com' \
    --to=theophilusx@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=kfogel@red-bean.com \
    --cc=laksvij@gmail.com \
    --cc=sdl.web@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.