Is sending email through an SMTP server on the same machine as my web application more or less efficient than using PHP mail()?
Observing members:
0
Composing members:
0
6 Answers
I’m confused by your question. Wouldn’t PHP mail() ultimately be using whatever SMTP server you use to send mail?
As far as I know, it’s a built in PHP service? You can use the PHP mail function on servers without an SMTP server installed, and mail will be delivered.
The config file actually lets you specify SMTP server details, which swaps out the built-in service.
That’s the way I’ve always understood it, anyway.
Sending it through SMTP is going to be much faster. With PHP mail you end up tying up your PHP parser along with your mail client. And @andrew is correct. The PHP mail function simply uses the mail binary present on your server (ie sendmail, postfix, or some other sendmail wrapper).
Furthermore, the reason it is slower to use the PHP mail function is because it opens and closes an SMTP socket for each mail sent. Of course if you’re just using it for a single email then whatever, but for larger mailings you’ll definitely notice a performance hit. Also using the PHP mail function can sometimes lead to missing emails.
Alrighty, thanks guys. Help appreciated.
Answer this question
This question is in the General Section. Responses must be helpful and on-topic.