I also need my php applications to be able to send our email using the mail function. Therefore I need to install sendmail and enable it in my php.ini file. Install Sendmail
apt-get install sendmail
ps -aux | grep sendmail
I just had a problem where php mail wouldn’t send therefore had to not add this step and it worked?
replace ;sendmail_path = with sendmail_path = /usr/sbin/sendmail
If you are using an external email provider and are using Ubuntu to send emails to yourself it will not work. The reason for this is Sendmail is configured to send email locally if it is the same domain name. So you need to do the following. Edit the config file
sudo nano /etc/mail/sendmail.mc
Add these lines to the bottom of the file (where example is your domain name.
define(`MAIL_HUB', `example.com.')dnl define(`LOCAL_RELAY', `example.com.')dnl
sudo sendmailconfig service sendmail restart
hostname /etc/hosts 127.0.0.1 localhost.localdomain localhost myhostname
echo -e "To: [email protected]\nSubject: Test\nTest\n" | sendmail -bm -t -v