7

I am using php and mysql.

I am going to send 10k++ (ten thousands plus) emails to update my subscribers, and this is the first time I am going to send them. I will use php mail function, basically here is what I will do:

First get the data from database:

Select name, email FROM data

After that, using while loop to send the data:

while($r = mysql_fetch_assoc($exe)){
    ...
    if($mail){
        echo "success<br>";
    } else {
        echo "failed<br>";
    }
}
echo "Sent all";

I include the if.. else statement, to ensure that each email is sent successfully. Is there anything I need to take care of? Will I have any problems when SENDING TO 10K++ users?

Is there a limit of numbers of emails that you are going to sent?

1

5 Answers 5

10

Please be aware of this note from the mail documentation:

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

Sign up to request clarification or add additional context in comments.

3 Comments

What library do you use for sending blast email? Pear:: mail?? I am going to study that stuff. Thanks
use pear::Mail_Queue, not mail
what about PHPmailer with gmail? could it work fine or has the same problem? is the problem the time_execution limit or something else?
6

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

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

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

2 Comments

Omg, I didnt know that. So, you normally use "phpmimemessage" to send out 10k++ emails? Which library you are using?
I have done something much more complex, but yes, I was using this library to do mass mailing (newsletters). Mimemessage is quite old now, there are better libraries now, see other answers, or google for them. My script was running in the background from CLI however, without time limitations.
2

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

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

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

Comments

0

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

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

Comments

0

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

It will really do a good job.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.