h1. How to send email using two smarthosts, easy and reliable way Recently I needed to use two email addresses, both for sending and receiving mail. I could use "mutt":http://www.mutt.org for everything, but I prefer separating receiving mail, reading it and sending into three separate programs. So, I tried to configure "exim4":http://www.exim.org, which I have already been using for sending mail via one smarthost, for that, but it's bloated piece of crap, the only sane way of interacting with which is debian configuration, which does not support multiple smarthosts. So I tried several MTAs until I found "opensmtpd":https://www.opensmtpd.org/. It still uses some kind of homebrew config system but it's quite okay. So here's approximately how do you send mail via appropriate smarthost, based on sender address: bc.. # /etc/opensmtpd.conf listen on localhost table aliases file:/etc/aliases table sender1 { myfirstaddress@host1 } table sender2 { mysecondaddress@host2 } table secrets db:/etc/mail/secrets.db # local mta functionality accept for local alias <aliases> deliver to mbox accept for any sender <sender1> relay via tls+auth://mail1@host:587 auth <secrets> accept for any sender <sender2> relay via tls+auth://mail2@host2:587 auth <secrets> p. To fill /etc/mail/secrets.db with your passwords, create /etc/mail/secrets with something like: bc. mail1 user1:password1 mail2 user2:password2 and run @makemap /etc/mail/secrets@. "myfirstaddress@host1" and "mysecondaddress@host2" are your emails, "tls+auth://mailX@hostX:587" are your SMTP connection details (see @man smtpd.conf@ for details), userX:passwordX are your SMTP credentials.