Search code examples
phpemailsmtpmassmail

mass mailing php


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?


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.