John Siu Blog

Tech - Business Tool, Personal Toys

Tiny VPS Postfix - Part 2 - Non-Linux Outgoing Account

☰ Table of Content

In the last part I show a minimal setup of Postfix. It allow incoming emails to be forwarded to specific external email address(es).

Series Content

Replying email with my own domain

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 flagged 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 sasldb2. It is easy to install and configure.

Installing

1
apt-get install sasl2-bin

This will pull in the required sasl2 library and command line utilities required to use sasldb2.

Setup Postfix

To have postfix to use sasldb2, modify /etc/postfix/sasl/smtpd.conf as follow:

1
2
pwcheck_method: auxprop
mech_list: plain login

Then restart postfix:

1
sudo service postfix restart

Create sasldb2 users

To create a user in sasldb2, use following command:

1
saslpasswd2 -c -u <domain> -a smtpauth <username>

For example, my domain is johnsiu.com, and I want to have a new email testing@johnsiu.com:

1
saslpasswd2 -c -u johnsiu.com -a smtpauth testing

Finalizing

The actual sasldb2 file is located at /etc/sasldb2. Make sure it has the following permission:

1
-rw-rw---- 1 postfix sasl sasldb2

What if sasldb2 doesn’t seems to work

Then it is likely that your postfix is run with chroot. Just copy sasldb2 to the chroot /etc/:

1
cp -a /etc/sasldb2 /var/spool/postfix/etc/

You will have to do that every time you modify sasl2 password, add/del sasl2 user.

Now you should able to configure your email client(Thunderbird, Outlook, etc) to use your VPS as outgoing smtp server.

John Siu

Update: 2020-09-01
comments powered by Disqus