简体   繁体   中英

Sending Multiple Emails PHP

It's a pretty straight forward question.

I have a php script that sends birthday wishes to all my customers. The subject of the mail is customized for each user(Happy Birthday, $name). Till now the script is working as it should be.

But I'm afraid that if the number of customers is very high, the execution time may cross the maximum execution time(which is 30 seconds). Is there any solution to this so that my script doesn't stop before sending emails to all the customers ?

I've found two different approaches to my problem. As Fred -ii suggests, I can use ini_set('max_execution_time', 0);

This would cause the script to never timeout.

Or I can use the set_time_limit ( int $seconds ) function. ( Documentation )

I can use set_time_limit(0); so that the script will run forever - however this is not recommended and my web server might catch me out with an imposed HTTP timeout (usually around 5 minutes). Since I've set up a cron job to send the mails, HTTP timeout shouldn't be a problem.

Use BCC headers in your php mail script refer

before that check your mail server if they have any restriction on sending emails like google

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM