Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: mail() vs SendMail

a simple question: which one has good performance for sending mails in bulk?

mail() function or sendmail

which one is used by popular PHP list manager packages?

like image 637
ankitjaininfo Avatar asked Dec 10 '09 20:12

ankitjaininfo


2 Answers

Well the mail() function is not really suitable for emails sent in bulk because it opens and closes an SMTP socket for each email you send, which is far from being efficient. If you look at PEAR::Mail it allows you to use 3 backends: mail, sendmail and plain SMTP. For what it's worth, I've personally preferred SMTP because it's easy to support on both Linux and Windows.

If you wish to send mails in the background using a queue, PEAR::Mail_Queue might be a solution.

like image 51
Percutio Avatar answered Oct 01 '22 18:10

Percutio


sendmail is a Mail Transfer Agent (MTA). On UNIX and Linux based systems, PHP's mail() function simply relays the email though sendmail (or a compatible MTA). For sending bulk email, you may want to look into directly connecting to an SMTP server. Zend Framework provides an SMTP transport.

like image 42
Jordan Ryan Moore Avatar answered Oct 01 '22 19:10

Jordan Ryan Moore