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 "".

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/

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/ > /etc/mail/

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... :-)

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

Leave a Reply

Your email address will not be published.