Send Emails from PHP on Ubuntu localhost LAMP setup

In this article, I will walk you through the process of configuring your local, Ubuntu based development machine to send emails from within PHP and also from the command line terminal. In a nutshell, you need to install and configure a mail server on your local computer. The mail server that we are going to use is Postfix. So without any further delay, lets get started.

Open up the terminal and, first of all, enter the following command:

It will make available the “mail” command on your terminal and also will install all the programs that it depends on. Our desired mail server Postfix is one of them. During installation, accept the defaults as configuration options of Postfix when asked.

Once the installation is complete, type following command: