Step 1 – Create mail.yourdomain.com

Add an MX record to your DNS using the following parameters:

Hostname : mail



Priority: 10

Step 2 – Install and configure postfix

sudo apt-get install postfix 1 sudo apt-get install postfix

Don’t enter anything during the installation. In the next step we will be configuring postfix more precisely, and any configuration set now will be overwritten.

sudo dpkg-reconfigure postfix 1 sudo dpkg-reconfigure postfix

Reference my configuration if you aren’t sure what to enter:

General type of mail configuration : Internet site

System mail name : mail.notblog.org

: Root and postmaster recipient : notblog (Your sudo-privileged account, not root)

: (Your sudo-privileged account, not root) Other destinations to accept mail for : localhost, mail.notblog.org, notblog.org

: Force synchronous updates on mail queue? : No

: Local networks : 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128

Mailbox size limit :

: Local address extension character : +

: Internet protocols to use: all

Step 3 – Change spool format to Maildir

sudo postconf -e "home_mailbox = Maildir/" 1 sudo postconf -e "home_mailbox = Maildir/"

Step 4 – Install IMAP and POP3 support

sudo apt-get install courier-pop courier-imap 1 sudo apt-get install courier-pop courier-imap

Answer No when asked about setting up a web interface. There are much better alternatives to using courier for web mail. I recommend roundcube. Check back soon for a guide on using web mail.

Step 5 – Add aliases for multiple domains and mail accounts

This step is optional. Following it will allow you to:

Handle mail for multiple domains with a single mail server.

Forward multiple mailboxes (webmaster, sysadmin, etc.) to a single mailbox.

sudo postconf -e "virtual_alias_domains = notblog.org maybeblog.net ablog.com" sudo postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual" 1 2 3 sudo postconf -e "virtual_alias_domains = notblog.org maybeblog.net ablog.com" sudo postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"

Line 1 : Enter the domain name this mail server will be used for as well as any other domains hosted on this machine. This will allow you to configure all of the domains to send mail to a single account. Separate the domains with spaces. If you aren’t using any other domains, enter the main domain only.

Line 2: This points postfix to the alias map at /etc/postfix/virtual which we will be creating in the next step. This file will describe where to forward mail sent to certain domains and/or mailboxes.

Write the following to /etc/postfix/virtual, adding domains and mailboxes you’d like to be forwarded:

webmaster@notblog.org notblog sysadmin@notblog.org notblog info@notblog.org notblog webmaster@maybeblog.net notblog webmaster@ablog.com notblog 1 2 3 4 5 6 7 8 9 10 11 webmaster@notblog.org notblog sysadmin@notblog.org notblog info@notblog.org notblog webmaster@maybeblog.net notblog webmaster@ablog.com notblog

Then run postmap to optimize the alias map. Postfix will read the file much more quickly if this step is taken.

sudo postmap /etc/postfix/virtual 1 sudo postmap /etc/postfix/virtual

Step 6 – Install dovecot

sudo apt-get install mail-stack-delivery 1 sudo apt-get install mail-stack-delivery

Step 7 – Restart postfix

sudo service postfix restart 1 sudo service postfix restart