10

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 [email protected] and send an e-mail with a From: [email protected] header, Gmail will rewrite the header to From: [email protected].

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="[email protected]"'
folder-hook =work 'set sendmail="/usr/bin/nbsmtp -f [email protected] -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 [email protected] 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

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

1 Answer 1

4

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

identity [email protected]
        hostname smtp.googlemail.com:25
        username "[email protected]"
        password "secret"
        starttls enabled
        default

identity [email protected]
        hostname smtp.googlemail.com:25
        username "[email protected]"
        password "evenmoresecret"
        starttls enabled
        default
4
  • So if I send an e-mail through esmtp that's from [email protected], it will automatically use the credentials from the first identity, and likewise for e-mails from [email protected]? Commented 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
    Commented Oct 5, 2010 at 15:09
  • Excellent. I'll try that sometime today and accept this if it works Commented 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
    Commented Jul 9, 2020 at 17:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .