Thursday, 8 March 2012

Internet Mail With Postfix

Setting up an Internet mail server with postfix is pretty easy.

apt-get install postfix mailutils alpine

Choose "internet site" when asked.

You will require fully qualified domain name (FQDN) and with properly configured MX record.

You can use the "dig" command to verify your MX record. The output will include the following lines;

dig mx

;; ANSWER SECTION:    2857    IN    MX    10

;; ADDITIONAL SECTION:    2862    IN    A

Your MX record should point to the A record for your mail server as it does in the above example.

The mail server must of course be contactable from the Internet.

Now, we need to configure a few things in postfix. Edit

sudo vi /etc/postfix/

Modify the following lines with the details shown as bold

myhostname = 
mydestination =, localhost.localdomain, localhost

If you are running behind NAT/proxy you will need to ensure that port 25 is forwarded from your router and advise postfix it is operating behind a NAT/firewall.

Add this line to the file;

proxy_interfaces = 
The address must be the same as the mail server IP that is shown in the ADDITIONAL SECTION from our dig command from before.
Restart postfix;
 sudo service postfix restart 

Try sending an email to an external address;

mail -s Test
Assuming you get the mail you should reply to it.
You can check whether it arrives using alpine;
Select "Folder List" ("L" key) to see any messages.

No comments: