Replying email with my own domain
In the last part I show a minimal setup of Postfix. It allow incoming emails to be forwarded to specific external email address(es).
However, there are situations we would like to reply or sent with our own domain. Especially with today tighter email security setup, relaying through others email server (eg. your isp) will likely have your email flaged as spam, if not outright rejected.
It will be way over kill to setup postfixadmin and mysql for a few email addresses. On the other hand, it is undesirable (at least for me) to setup a local Linux account on the VPS just for sending email.
So is there a simple way to setup smtp authentication with postfix without using Linux account?
SASLDB to the Rescue
To enable smtp authentication with Postfix without Linux account or a database, we can use sasldb. It is easy to install and configure.
apt-get install sasl2-bin
This will pull in the required sasl library and command line utilities required to use sasldb.
To have postfix to use sasldb, modify /etc/postfix/sasl/smtpd.conf as follow
pwcheck_method: auxprop mech_list: plain login
Then restart postfix
sudo service postfix restart
Create sasldb users
To create a user in sasldb, use following command
saslpasswd2 -c -u <domain> -a smtpauth <username>
For example, my domain is johnsiu.com, and I want to have a new email email@example.com
saslpasswd2 -c -u johnsiu.com -a smtpauth testing
The actual sasldb file is located at /etc/sasldb2. Make sure it has the following permission:
-rw-rw---- 1 postfix sasl sasldb2
What if sasldb doesn’t seesm to work?
Then it is likely that your postfix is run with chroot. Just copy sasldb2 to the chrooted /etc/
cp -a /etc/sasldb2 /var/spool/postfix/etc/
You will have to do that everytime you modify sasl passowrd, add/del sasl user.
Now you should able to configure your email client(Thunderbird, Outlook, etc) to use your VPS as outgoing smtp server.