mass mailing php

1.3k views Asked by At

I have a small database with 534 registered e-mails (newsletter).

I know how to send e-mail to all e-mail address from my database, but the problem is with the limitation where the page is hosted. I'm limited to 200 e-mail / hour, and if I force to send to all address I might be banned.

At the beginning I used to send with a loop ( for() and foreach() ), I selected all e-mails than send the message with smtp.

Yesterday I was checking my notifications and I saw a Warning window from the web hosting company, I might be banned because I tried to send over 500 e-mail in less then 1 hour !

What should I do?

5

There are 5 answers

0
User 99x On BEST ANSWER

The following steps would help.

  1. First add a reference in table as a status flag whether the email is send to that specific customer or not. you can use boolean for this.
  2. Write the email sending script to run only for 200 loop, where you should get the 200 email addresses which the email have not been send. (where the flag is not send)
  3. Inside the loop, while sending the email to each user, update their flag as send in the database.

Once you did the above script all you have to do is, set a cronjob which can execute every hour and call your php script inside that.

hope this helps.

0
noel On

If your using mail() (I can't tell without code) then read this from php.net...

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.

Pear is no fun in my book. I tend to agree with this post go with something like SwiftMailer

1
Ravi Kant Mishra On

You can send multiple emails in a single call like this

CC = "[email protected]; [email protected]". BCC = "Firstemailaddress; secondemailaddress"

But it has also a limit.

0
Jon On

You can run the script every hour and in your select statement change the limit values to work within your range, and you can save those value in the DB and set it back to 0 when done, or even in a simple file that is created and then reset after all the emails have been cycled.

0
Dusda On

We use an outside email system for our web applications. I personally recommend SendGrid, it handles the scaling and provides some pretty useful analytics (very handy for tracking down bad addresses).