Install required software:
sudo apt-get install sendmail php-mail postfix
Restart sendmail
sudo service sendmail restart
or
sudo /etc/init.d/sendmail restart
Restart apache service
sudo /etc/init.d/apache2 restart
or
sudo service apache2 restart
#Test your php mail function
<?php
if(mail(“xxx@gmail.com”, “Subject here”, “Message body here”))
echo “Email working well :)”;
else
echo “Something is wrong”;
?>