Thread: PHP Mass Email

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    12
    Rep Power
    0

    PHP Mass Email


    Hello. My site has about 15k registered users and I want to send mass mail to all who were inactive for more than a week.
    I know how to check if they were online for more than a week, but the problem is how I'm going to send 15k emails without the server to crash?
    How I can do it smart without wasting too much resources for 15k emails (that some of them are fake)
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,621
    Rep Power
    595
    This is not necessarily a PHP question (personally, I'd use perl) since any scripting language could be used. The real issue is the time and resources involved. I'd suggest you write your script to send some number of emails (say 100) then sleep for some appropriate time (maybe 10 minutes). Obviously you would run your script in background. This will take quite some time to send 15K messages but it will throttle overloading the network and using too may server resources.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Dec 2004
    Posts
    3,031
    Rep Power
    377
    no one does this. it would be a nuisance AND they will more likely just switch off.

    if you are going to send, do it once per month or fortnightly.

    AND as for sending emails, I would use something like phplist who can send emails for you. If you were going to use it yourself then i would do sleep(rand(1,10)) so the server sleeps randomly between 1-10 secs. and yeh you would need ssh access, you wouldnt be able to do it through browser.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    12
    Rep Power
    0
    Sorry for not being clera enough, but I need to send the emails just one time to all inactive members.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,621
    Rep Power
    595
    That is what I surmised. My suggestion stands.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  10. #6
  11. Mad Scientist
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2007
    Location
    North Yorkshire, UK
    Posts
    3,661
    Rep Power
    4124
    queue them

    populate a database table with a list of email addresses (and email content if it will vary greatly)

    Then write a script that sends 100 at a time (for example)

    this script will select the next batch marked as "not sent", flag them all as "processing" then loop over sending one at a time and flagging them as "sent"

    then write a cron job to run the above script once a minute. 15000 emails at 100/minute would take 2 and a half hours.

    Monitor your server load and adjust the limits to suit

    EDIT

    I'm the developer for a bulk mailing company. Across our 150 clients we send out several million emails per month and this is exactly how we do it (we limit to 300/minute on our dedicated server...but are moving towards the cloud for greater scalability and client reputation isolation)
    Last edited by Northie; October 1st, 2013 at 11:21 AM.
    I said I didn't like ORM!!! <?php $this->model->update($this->request->resources[0])->set($this->request->getData())->getData('count'); ?>

    PDO vs mysql_* functions: Find a Migration Guide Here

    [ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    12
    Rep Power
    0
    Originally Posted by Northie
    queue them

    populate a database table with a list of email addresses (and email content if it will vary greatly)

    Then write a script that sends 100 at a time (for example)

    this script will select the next batch marked as "not sent", flag them all as "processing" then loop over sending one at a time and flagging them as "sent"

    then write a cron job to run the above script once a minute. 15000 emails at 100/minute would take 2 and a half hours.

    Monitor your server load and adjust the limits to suit

    EDIT

    I'm the developer for a bulk mailing company. Across our 150 clients we send out several million emails per month and this is exactly how we do it (we limit to 300/minute on our dedicated server...but are moving towards the cloud for greater scalability and client reputation isolation)
    Thank you very much! You helped me alot.

IMN logo majestic logo threadwatch logo seochat tools logo