Sendmail on Ubuntu

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?

;sendmail_path =      
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/

Add these lines to the bottom of the file (where example is your domain name.

define(`MAIL_HUB', `')dnl
define(`LOCAL_RELAY', `')dnl

Config Sendmail

sudo sendmailconfig
service sendmail restart

Change your host files

/etc/hosts localhost.localdomain localhost myhostname

Test Sendmail

echo -e "To: [email protected]\nSubject: Test\nTest\n" | sendmail -bm -t -v