I use mutt as my e-mail reader, and nbSMTP as my SMTP client. I check e-mail from a half dozen accounts and sort them into miscellaneous folders in my maildir. Some of the folders are account-specific, but some contain e-mails from multiple accounts in one folder

A number of the accounts are through Gmail, which has the unfortunate security feature of preventing users from sending from addresses that aren't theirs. Thus if I tell nbSTMP to authenticate as user1@gmail.com and send an e-mail with a From: user2@gmail.com header, Gmail will rewrite the header to From: user1@gmail.com.

I've worked around this somewhat by adding folder hooks for the folders that are account-specific; when I switch to one of those folders the hook changes my sendmail command to pass nbSMTP the appropriate command-line arguments:

folder-hook =work 'set from="work@example.com"'
folder-hook =work 'set sendmail="/usr/bin/nbsmtp -f work@example.com -U work -P password"'

However, this doesn't work for the folders that hold mail from multiple accounts, and it doesn't work if I try to e.g. send e-mail from work@example.com when I haven't switched to the work folder (since the folder hook hasn't run). Is there a way to control how nbSMTP authenticates based on the From header in the outgoing e-mail? I don't think nbSMTP has the flexibility to handle it itself, so I'm pretty sure it will have to be some kind of mutt configuration like the folder-hook method I'm currently using, but I haven't figured out how to do it. If necessary I can probably switch SMTP clients, if there's another that does provide the necessary functionality

  • email is a very valid tag here.
    – Stefan
    Oct 8, 2010 at 8:31

1 Answer 1


You could switch to esmtp, there it is pretty trivial:

identity myself@gmail.com
        hostname smtp.googlemail.com:25
        username "myself@gmail.com"
        password "secret"
        starttls enabled

identity mysecondaccount@gmail.com
        hostname smtp.googlemail.com:25
        username "mysecondaccount@gmail.com"
        password "evenmoresecret"
        starttls enabled
  • So if I send an e-mail through esmtp that's from myself@gmail.com, it will automatically use the credentials from the first identity, and likewise for e-mails from mysecondaccount@gmail.com? Oct 5, 2010 at 14:40
  • It will use the identity matching the envelope-from, i.e. the address passed to it in the -f parameter. Mutt passes the from address there if you set "set use_envelope_from" in mutrc, see wiki.mutt.org/?LightSMTPagents/Esmtp
    – fschmitt
    Oct 5, 2010 at 15:09
  • Excellent. I'll try that sometime today and accept this if it works Oct 5, 2010 at 16:54
  • Ten years later!! Help: Is esmtp still a good choice? Is there a better one? Anyone still using it? How do I call it from Alpine? Or does it run as a once-only daemon like postfix?
    – CPBL
    Jul 9, 2020 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.