Sometimes I need to test the email functionality of a php website on my local machine. The best and easiest (to configure) way I found so far is using sendmail as smart host.
A smart host is a software which allows an SMTP server to route email to an intermediate mail server rather than directly to the recipient’s server.
The only thing you need is the SMTP address of your internet service provider.
Normally you can find it quite easily on the internet. For example my ISP is Virgin Media and their SMTP server is “smtp.virgin.net”.
First of all you have to install sendmail. With Ubuntu you type:
sudo apt-get install sendmail
Then open your configuration file:
sudo vi /etc/mail/sendmail.mc
and append or modify the following line which defines your ISP SMTP server:
Remove the “dnl” word at the end in case there is..
Now login as root and regenerate the sendmail config file with:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
and restart sedmail service:
service sendmail restart
Done. Now your local machine should be able to send emails.
Of course there are many ways you can test it. The easiest for me is from the php interactive shell:
php -a mail('[email protected]','TEST','WORKING?!?');
One thought on “How to configure sendmail as a SMART HOST”