How to setup a local SMTP email server


If you need to setup a local SMTP email server for developer or testing purposes, this tutorial might be helpful for you. Bear in mind that this is made for an Ubuntu OS environment, with an Gmail SMTP server (you can use whichever you want).

First of all, you need to install ssmtp, to do so, let’s do the following:

Once installed, you will need to configure  /etc/ssmtp/ssmtp.conf file, commenting out the mailhub line, and adding the followings, at the bottom of the file:

Afterwards, remember to restart your apache, and you will be able to send emails from your local.

Note: The following code-snipper might help you to test email sending:

Or, for a quick try, you can perform the following on your CLI:

 

Happy coding!