Install Sendmail on Ubuntu
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
Check its working
ps -aux | grep sendmail
Change php.ini
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
Using external mail provider like Google Apps
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
Config Sendmail
sudo sendmailconfig
service sendmail restart
Change your host files
hostname
/etc/hosts
127.0.0.1 localhost.localdomain localhost myhostname
Test Sendmail
echo -e "To: [email protected]\nSubject: Test\nTest\n" | sendmail -bm -t -v