Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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

You can send multiple emails in a single call like this

CC = "emailaddress1@xxxx.com; emailaddress2@xxxxx.com". BCC = "Firstemailaddress; secondemailaddress"

But it has also a limit.

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.

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top