Postfix and Aliases

Just a quick post on a simple Postfix installation and some steps that tripped me up a little recently.

I installed a basic version of Postfix on Debian and didn’t want to go through the hassles of configuring a MySQL database for managing users etc… I decided to just use the simple aliases file to manage users. To do this I needed to specify the following in my main.cf file:

 Bash |  copy |? 
myhostname = example.co.uk
mydomain = example.co.uk
myorigin = example.co.uk
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, $mydomain, localhost.$mydomain, mail.example.co.uk

and this in my /etc/aliases file:

 Bash |  copy |? 
postmaster: root
root: example@gmail.com
example: example@gmail.com

I also ran into two more issues with the aliases file:

1. Dictionary issue with /etc/aliases

 Bash |  copy |? 
postfix/smtpd[19065]: fatal: open dictionary: expecting "type:name" form instead of...

The issue here was that Postfix couldn’t read the aliases file. It just needed to convert the /etc/aliases file into the /etc/aliases.db file. The question was how, the answer, like this:

 Bash |  copy |? 
sudo newaliases; sudo postfix reload 


2. Aliases database out of sync

 Bash |  copy |? 
database /etc/aliases.db is older than source file /etc/aliases

The aliases database was not up to date with the aliases file. To fix this I ran the commands above.

About the author
Jonathan Holloway is a developer based in Bristol, UK working with Java and Python technologies in the area of data analysis.