Postfix is an open source MTA or SMTP server. In this tutorial we will deploy a very simple configuration of Postfix. We will see in other tutorials how we can deploy more complex configuration including user authentication, SSL and message signing.
This tutorial considers the following software and environment:
We start by installing Postfix. Issue the following command in the console:
Now we may also install a simple SMTP client like mailutils so we can test the configuration at the end:
One of the most important Postfix configuration files is main.cf. The file is usually located at:
/etc/postfix/main.cf.
Edit the file and add the following lines where domain1.com is your mail domain:
Uncomment the following lines:
Comment the following lines:
Now we need to configure the mailbox owner. Create the user and the respective group by issuing the following command in the console:
We go back again to /etc/postfix/main.cf and add the following lines:
Edit the file:
/etc/postfix/vhosts
Insert your mail domains in the file, one domain per line:
Edit the file:
/etc/postfix/vmaps
Insert as much users you need in this file - one user per line - following the pattern:
All mail that is sent to user@domain1.com will be stored in domain1.com/user/ directory.
Now we generate the mail database file by issuing the following command in the console:
After this step you should a mail database file at:
We may start Postfix now by issuing the following command:
After the service is started we may use mailutils to test if the mail server is ok. If you already installed mailutils you may issue the following command in the console:
You will be asked to insert Cc (carbon copy). You may leave it empty and press ENTER. Now insert the Subject and press ENTER again. Finally insert your message text and press ENTER to go into a new empty line and then press Ctrl+D to send the message.
If everything went OK you should have a new mail message in:
Configuring a mail server can be problematic especially if you are doing it for the first time. Postfix has a robust logging mechanism and by looking at the logs you can almost certainly check what went wrong. The log file is located at:
showing up on this page!