Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question
    
email is a very valid tag here. –  Stefan Oct 8 '10 at 8:31
add comment

1 Answer

up vote 3 down vote accepted

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
        default

identity mysecondaccount@gmail.com
        hostname smtp.googlemail.com:25
        username "mysecondaccount@gmail.com"
        password "evenmoresecret"
        starttls enabled
        default
share|improve this answer
    
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? –  Michael Mrozek Oct 5 '10 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 '10 at 15:09
    
Excellent. I'll try that sometime today and accept this if it works –  Michael Mrozek Oct 5 '10 at 16:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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