I have read that using mail() in a for loop to send a lot of emails ( around 1k-10k ) emails is not advised due to the fact that it can be resource intensive hence or the script might take so much time that it ti,es out. However what if i append all the emails into the Bcc: header as follows and make only 1 call to mail.
1. Is this better? 2.Will it still be resource hungry? 3.What would be the best way to handle mailing to many email addresses from PHP. This is for a newsletter (not SPAM) application I am working on. 4.How does this compare against using sockets to directly speak to the SMTP server from a efficiency aspect?
The code I am planning on using (which I got online too ) is as follows :
$email = "[EMAIL PROTECTED]"; $subject = "test";
$body = "This is a test.";
$headers = "From: [EMAIL PROTECTED]"; $headers .= "Reply-to: [EMAIL PROTECTED]";
//the following willl have all the email addresses which will receive the email
$headers .= "Bcc: [EMAIL PROTECTED]"; $headers .= "Bcc: [EMAIL PROTECTED]"; $headers .= "Bcc: [EMAIL PROTECTED]"; $headers .= "Bcc: [EMAIL PROTECTED]"; $headers .= "Bcc: [EMAIL PROTECTED]"; //..and so on...
$headers .= "Content-Type: text/plain; charset=iso-8859-1\n";
mail ($email, $subject, $body, $headers);
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php