Setup PHP mail function.

April 3, 2013 14.2k views
Hi there, can anyone tell me how to setup the mail function in PHP on an Ubuntu VPS? Thanks in advance! Francis
7 Answers
I believe that the php mail() function will use your local MTA by default which on most normal installed linux servers will just be:


Have you tried using the mail function and ran into issues?
I tried the mail function to send an email and I get no errors. But the email just never arrives.
Thanks again for the reply.
There's an excellent tutorial on YouTube that I've come across.

It looks to me like he's using the Pear package in this example.

Video Here:
Good question!

SMTP class is an option but network latency between cloud server and SMTP server will delay PHP script. If SMTP server or network would be down then PHP will hang and hole server may hang (e.g. ngnix + 16 FastCGI PHP processes - 16 emails and server is down waiting for SMTP server)

With sendmail you send email and forget.

Is there lightweight sendmail that will relay email to other SMTP server like Gmail using login/password and SSL?
@Max: Try using Postfix to relay mail to Gmail
Wow! Great! That what I was looking. Perfect!
For applications with php wordpress mail, just set like this video. Greetings!
Have another answer? Share your knowledge.