How to configure sendmail as a SMART HOST

This post is over 3 years old, so please keep in mind that some of its content might not be relevant anymore.

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:

define(`SMART_HOST',`smtp.virgin.net')

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?!?');

Enjoy… :-)

One thought on “How to configure sendmail as a SMART HOST”

Leave a Reply

Your email address will not be published. Required fields are marked *