David Champion wrote:
> * On 29 Feb 2012, Chris Burdess wrote: 
> > OK, so after a bit more experimentation the symptoms are as follows:
> > 
> > I have 2 accounts which I am switching between with account-hook. Both use
> > smtp_url: the first just straight SMTP, the second is SMTPS (the GMail
> > account). Both use SASL authentication for SMTP.
> > 
> > If I set smtp_url to the first account and then switch to the second
> > account and set smtp_url there, authentication fails.
> 
> Good information.  Here's a snippet of the manual on account-hook:
> 
> | If you happen to have accounts on multiple IMAP, POP and/or SMTP
> | servers, you may find managing all the authentication settings
> | inconvenient and error-prone. The account-hook command may help. This
> | hook works like folder-hook but is invoked whenever Mutt needs to
> | access a remote mailbox (including inside the folder browser),
> | not just when you open the mailbox. This includes (for example)
> | polling for new mail, storing Fcc messages and saving messages to a
> | folder. As a consequence, account-hook should only be used to set
> | connection-related settings such as passwords or tunnel commands but
> | not settings such as sender address or name (because in general it
> | should be considered unpredictable which account-hook was last used).
> 
> Account-hooks execute whenever something (anything) in mutt tries to
> grab a connection from the connection manager.  Thus you could be
> executing an imap account-hook after the smtp account-hook is triggered,
> or something like that.
> 
> It's possible that we're still looking at a mutt bug but it seems likely
> that it's just a quirk of account-hook in play, given what else you
> wrote:
> 
> > If I start mutt without smtp_url set and then switch to the second account,
> > or open that account directly (both of which involve just 1 set smtp_url),
> > authentication succeeds.
> > 
> > If I set smtp_url to the second account and then switch to the first
> > account and set smtp_url there, authentication succeeds.
> 
> So I'm crossposting to mutt-users to solicit comments from people who
> use account-hook (I don't).  If you'll post your account-hooks in the
> order they appear in your muttrc, probably someone can help.
> 
> When posting account configuration, redact the personal information
> as needed, but please do distinguish user1 from user2, password1 from
> password2, etc.

Sure. It goes like this:

.muttrc:
account-hook 'myhost' 'source ~/.muttrc-myhost'
account-hook 'imap.gmail.com' 'source ~/.muttrc-gmail'
macro index { '<change-folder>imap://myhost/<enter>'
macro index } '<change-folder>imaps://imap.gmail.com/<enter>'

.muttrc-myhost:
set folder=imap://myhost/mail
set postponed=imap://myhost/mail/drafts
set record=imap://myhost/mail/sent
set spoolfile=imap://myhost/inbox
set imap_user=me
set imap_pass=myimapsecret
set smtp_url="smtp://me:mysmtpsecret@mysmtphost/"
set smtp_authenticators="cram-md5"
set ssl_verify_host=no

.muttrc-gmail:
set folder=imaps://imap.gmail.com/
set postponed=imaps://imap.gmail.com/Drafts
set record=imaps://imap.gmail.com/Sent%20Messages
set spoolfile=imaps://imap.gmail.com/INBOX
set imap_user=me2@mygoogledomain
set imap_pass=googlepass
set smtp_url="smtps://me2@mygoogledomain:googlep...@smtp.gmail.com/"

-- 
Chris Burdess

Reply via email to