Create a development mail server on Ubuntu 14.04

Posted on

To get started install the postfix package with apt-get.

sudo apt-get install postfix

After the installation the package starts the configuration process.


First select Internet-Site and click okay by hitting the tab key.


After that you can select your hostname, from which your mails can be sent. With this the installation should be finished.

To test this create a new PHP file with the following content (Example from here):


$to= 'yourmailadress@yourhost.tld';
$subject = 'Testing';
$message = 'Hello';
$header = 'From: dev@yourselectedhostname' . "\r\n" .
    'Reply-To: dev@yourselectedhostname' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $header);

You can now run this file by opening a shell in the folder where you created the file and run the command “php file.php”.

Now you should get the mail in your mailbox. Pretty awesome right?

2014-10-02 22_24_14-Testing - - Gmail


As always, if you have any questions or if something breaks or doesn’t work, feel free to leave a comment.

One thought on “Create a development mail server on Ubuntu 14.04

Leave a Reply