I develop php backends for websites on the regular. And far to often I end up sending emails, and need to test their layouts by sending them to my primary email address. But wouldn’t it be MUCH more convenient to send them to an email address @localhost and keep my primary account clean? Well you’re about to.

As you may know the easiest way on Ubuntu to get up and running with php is through Postfix. So lets get started and install a couple packages. You can do this either in Synaptic or the terminal.

sudo apt-get install postfix, mailutils, courier-pop, courier-imap

Now we need to tell postfix we want to use MailDir style mailbox, and listen on localhost:

sudo postconf -e "home_mailbox = Maildir/"
sudo postconf -e "mailbox_command = "
sudo postconf -e "mydestination = localhost, mail.localhost"
sudo  /etc/init.d/postfix restart

Ok, as you can see you can also add more domains to “mydestination”, you can do as you please here. With a little luck our postfix should be configured. Next we need to actually create our MailDir mailboxes. These are simply folders in our home directory. You can do this in your file browser or the terminal:

mkdir ~/Maildir
mkdir ~/Maildir/new
mkdir ~/Maildir/cur
mkdir ~/Maildir/tmp

Now we have a place to store all of our messages. Finally we just need to configure Evolution to read our messages. You should already have evolution installed. This part is pretty easy. Create a new account at username@localhost where your username is your ubuntu login username. Set your Receiving to Maildir, and on the Sending options use sendmail.

Now you should be able to send and receive mail to username@localhost. It would be nice to test html emails in more than just Evolution, however not many email clients appear to support a Maildir receiving format. I’m not an email expert however, so I’m always up suggestions