Reputation: 2821
So, its coming towards the time of year again when our sports club mailing list gets swamped with new members (happens with the new academic year).
Last year we tried sending emails using php's mail()
function.
This worked fine for around the first 50 or so (and continues to work fine sending one email at a time). However, after around 50, mail()
claimed it had sent the mail, but no one ever received them on the other end.
I should point out, that in my implementation it simply does a loop through all the emails in our database and runs the following function:
function sendMail($from,$fromname,$to,$subject,$body){
$subject = stripslashes($subject);
$body = nl2br(stripslashes($body));
$headers = '';
$headers .= "From: $fromname <$from>\n";
$headers .= "Reply-to: $fromname <$from>\n";
$headers .= "Return-Path: $fromname <$from>\n";
$headers .= "Message-ID: <" . md5(uniqid(time())) . "@" . $_SERVER['SERVER_NAME'] . ">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "Date: " . date('r', time()) . "\n";
return mail($to,$subject,$body,$headers);
}
Does anyone know what could have caused this?
Upvotes: 0
Views: 153
Reputation: 345
Using Bcc without "To:"-Header makes the E-Mail "To:"-Header "undisclosed-recipients", those mails usually getting blocked by strict servers. I would not recommend this for newsletter stuff,´ you will get blacklisted. If you send this mail to a few users at the same ISP, you will get blacklisted for sure.
I would recommend a script which sends an amount of mails every 30 mins or so.
Upvotes: 0
Reputation: 14245
You are probably being blocked by ratelimit on the SMTP relay.
I would suggest instead of sending individual emails, set everyone to the BCC
field, with no one in the TO
and CC
field.
$headers .= 'Bcc: ' . implode(",", $email_array) . "\r\n";
Upvotes: 2