Topic: multi SMTP servers with mutt

Ok. So you have several email accounts and mutt manages them all - but you want to reply to emails with different "From:" tags that have to be sent via different smtp servers... well, here's your answer... (thanx to scottro's excellent work)

For the purposes of this RTFM, I have the following two email accounts:

John Doe  john@example.com
J. Doe    j.doe@work.com

each requires a mailserver suitable for its domain, so let's assume they're as follows, with work.com requiring authentication:

mail.example.com
smtp.work.com

First, install yourself a copy of msmtp - it's in pkgsrc and am betting it's in ports, etc.

msmtp works by being passed a "-f" switch by mutt which says who the email is "from" and uses this information to determine which smtp server to use. As such, let's configure ~/.muttrc to use msmtp as we need:

set sendmail="/path/to/msmtp"
set use_from=yes
set envelope_from=yes

In order to make the change in our email "From" header when in mutt, we include scottro's example. When you press <esc> followed by the corresponding number, command is displayed and this is enabled by pressing <enter> :

macro generic "<esc>1" ":set from=john@example.com realname='John Doe'"
macro generic "<esc>2" ":set from=j.doe@work.com realname='J. Doe'"

We now create the corresponding ~/.msmtprc file:

# example.com - home account
account example
host mail.example.com
from john@example.com
auth off

# work.com - work account
account work
host smtp.work.com
from j.doe@work.com
auth on
user johndoe
password s3cr3t

# Set a default account to use
account default : example

That should all make sense - it's just so easy!

Happy multi-smtp-server emailing

"UBER" means I don't drink the coffee... I chew the beans instead
             -- Copyright BSDnexus