Recently I was adapting a newsletter plugin for WordPress and needed the PHP mail() function for testing. However an Ubuntu desktop install is missing Sendmail – the MTA that PHP expects to find on a Linux PC.

I use a local Apache/MySQL server on a laptop to do a lot of my development – I don’t need a full mail server just to send mail.

Also SMTP servers on dynamically assigned IP addresses are so untrusted these days that you can be pretty much guaranteed that a decent spam filter will reject your email based on a RBL lookup. By using Google Mail’s authenticated SMTP service you bypass this restriction.

I think people should know that Google has very low limits about the number of emails you can send via your GMail account – on general, you won’t be able to send more than 500 emails a day. So while this is perfect option for low volume mailing, if you have a large number of registered users and want to send a newsletter to them, this won’t work.

Now my mail function is working fine and sending the mail. But one problem is occur, in From : address my email is sending not that one which is i mentioned in mail(). Even i had done the setting in ssmtp.cnf file.

Google are the culprits here – they will not let you use an arbitrary “From” address (for very good reasons).
However as Dennis points out this solution is not for production use.
To solve your problem either:
– verify the “from” address in your GMail account
or
– use an alternative SMTP server.

That is very simple and useful tutorial.. It works perfectly for me. Before I used sendmail and postfix. From both of them it returned true from mail() function. But there was no any mail in my inbox or spam. Then I tried with ssmtp as you explained and it worked well. Thank you very much for your post.

Hi,
Thanks for this nice tutorial.
I’m trying to use mail function. I’ve followed your tutorial and configured the ssmtp on my ubuntu server. But when I send the email on a php page, it shows ‘false’. I can’t find a clue why.