Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a limit when using php mail function?

Tags:

php

email

send

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?

like image 756
bbtang Avatar asked Oct 09 '09 11:10

bbtang


People also ask

How many emails can PHP mail send?

Thus, it is possible to send 20, 2000 or 20000 e-mails, with the mail function of PHP, without risk of being blocked.

Why my mail function is not working in PHP?

Make sure the localhost mail server is configuredWithout one, PHP cannot send mail by default. You can overcome this by installing a basic mail server. For Windows you can use the free Mercury Mail. You can also use SMTP to send your emails.

Why does PHP mail take so long?

It is the SMTP mail delivery (which PHP hands off the message to) which is taking time. Possibly, the delay you see is greylisting on the receiving server, meaning that the receiving mail server refuses to accept the message until the sending server (which your PHP script handed it to) tries a few times.


1 Answers

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.

like image 107
Greg Avatar answered Nov 05 '22 19:11

Greg