Tiny VPS Postfix - Part 2 - Non-Linux Outgoing Account
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
- Part 1 - Tiny VPS Postfix
- Part 2 - Non-Linux Outgoing SMTP Account <- You are here
- Part 3 - GMail As Email Client
- Part 4 - Postfix with Docker
- Part 5 - Docker, Postfix, Journald & Logwatch
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
|
|
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:
|
|
Then restart postfix:
|
|
Create sasldb2 users
To create a user in sasldb2, use following command:
|
|
For example, my domain is johnsiu.com
, and I want to have a new email testing@johnsiu.com
:
|
|
Finalizing
The actual sasldb2 file is located at /etc/sasldb2
. Make sure it has the following permission:
|
|
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/
:
|
|
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.