[ACCEPTED]-Is there a limit when using php mail function?-send

Accepted answer
Score: 10

Please be aware of this note from the mail documentation:

Note: It 6 is worth noting that the mail() function 5 is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP 4 socket for each email, which is not very 3 efficient.
For the sending of large amounts 2 of email, see the » PEAR::Mail, and » PEAR::Mail_Queue 1 packages.

Score: 6

No limit to the emails number, but there 14 is the time limit of the PHP script. See 13 the max_execution_time set in your php.ini, typically it's 12 20 or 30 seconds. If you don't know that, use 11 phpinfo() to find it out.

Moreover, you should 10 take some steps to prevent users from getting 9 too much emails. You should mark them as 8 sent, so they don't receive double posts 7 if you accidentally start the script twice.

Other 6 than that, you should note that php's mail 5 function is inherently not optimized at 4 all. You could try some libraries, like 3 phpmimemessage or any other, which will 2 allow you do to some caching, for example, among 1 many other features.

Score: 2

You should build a queue of emails sent/failed, so 6 you can try to resend failed attempts and 5 avoid re-sending emails if something should 4 go wrong.

Do not create a loop that tries to send 3 10k emails via mail()

Also, the most likely 2 limit you'll hit will be that of the mail 1 server of your ISP or host.

Score: 0

You can use pear::Mail_Queue http://pear.php.net/package/Mail_Queue/

It will really 1 do a good job.

Score: 0

You may also want to look at setting up 5 a "real" mailing list tool, such 4 as mailman, or at least using alias groups (if 3 possible).

Also, see the related questions 2 on serverfault: https://serverfault.com/questions/67154/sending-an-email-to-about-10k-users-not-spam, where PHPlist is mentioned, along 1 with others. And here - https://serverfault.com/questions/68357/whats-the-best-way-to-send-bulk-email.

More Related questions