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):
<?php $to= 'firstname.lastname@example.org'; $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?
As always, if you have any questions or if something breaks or doesn’t work, feel free to leave a comment.