0

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?

6
  • 1
    Can you show us your mailer code? Perhaps what the database structure looks like? Commented Aug 14, 2012 at 13:11
  • 2
    There's no "PHP sendmail() function". Please describe your setup in a bit more detail. Commented Aug 14, 2012 at 13:13
  • Perhaps also look into using something like code.google.com/a/apache-extras.org/p/phpmailer Commented Aug 14, 2012 at 13:24
  • Enlighten us with your code. Also, as right pointed in the above comment, no sendmail function exists in php. Commented Aug 14, 2012 at 13:26
  • Yeah sorry, was writing this without looking at the code, I forgot I defined a function called sendmail. Commented Aug 14, 2012 at 18:50

2 Answers 2

2

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";
Sign up to request clarification or add additional context in comments.

4 Comments

Yeah that sounds like what I originally thought. Is there a limit on how many people you can BCC?
Your only limitation with this would be limits of the SMTP server, as every recipient in the to, cc or bcc field is a separate email outgoing.
This sounds like the way forward then, is there any way to check this limit?
Best bet is to reach out to your hosting provider.
0

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.

3 Comments

Most of the people signing up are students and use webmail. Generally gmail or hotmail etc. Would this be a problem for them?
I just can talk for myself. I actually delete EVERY E-Mail with "undisclosed-recipients" because its in 90% of all cases just spam. I created a filter for that but I'm not sure if gmail has such filter active since I dont have a gmail account at all.
The "To" email address isn't a problem. We can just send it to the clubs own address.

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.