Sending mass emails.

Discussion in 'PHP' started by Narrator, Jan 15, 2007.

  1. #1
    hey guys,

    I am working on a script to send emails from a list of members.
    I need to be able to send the emails to between 100-200 people. Right now I am calling the email() function for each email but the browser ends up timing out before it goes through the list. What is best method of doing this?

    Thanks for the help!
     
    Narrator, Jan 15, 2007 IP
  2. solidphp

    solidphp Peon

    Messages:
    46
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This will keep it from timing out:


    set_time_limit(0);
    ignore_user_abort(true);
    PHP:
    Just put that at or near the top of your file.
     
    solidphp, Jan 15, 2007 IP
    Narrator likes this.
  3. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Assuming your host allows you to override the time out... which most don't.

    Firstly, I would suggest not using the native PHP function: I would suggest the PHPMailer library. I believe it may support 'delayed sending' or something like that but if not...

    Secondly, I would suggest essentially sending a handful of emails then outputting some HTML to the browser which will automatically reload the page. On the next load, send the next handful and so on.
     
    TwistMyArm, Jan 15, 2007 IP
    Narrator likes this.
  4. vvoole

    vvoole Peon

    Messages:
    38
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    TwistMyArm, PHPMailer don't support 'delayed sending'. This is just advanced library for sending email.

    I think sending e-mail by loading page isn't a good idea. Try to run script using system(''); or by Cron.
     
    vvoole, Jan 15, 2007 IP
    Narrator likes this.
  5. Narrator

    Narrator Active Member

    Messages:
    392
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Worked like a charm! Thanks
     
    Narrator, Jan 15, 2007 IP
  6. RaginBajin

    RaginBajin Peon

    Messages:
    87
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Why don't you look at something like PHPList?

    Let you manage the list and what not and it can control on how fast it sends out emails.
     
    RaginBajin, Jan 15, 2007 IP
  7. solidphp

    solidphp Peon

    Messages:
    46
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    No problem Narrator, glad it worked out for you.
     
    solidphp, Jan 15, 2007 IP
  8. tahaelearner

    tahaelearner Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I am using PHP mailer class for sending mass emails
    My hosting server allow me to send 300 email in an hour and 3000 per day
    So i am using cronjob for which is one after an hour and send email to 300 people
     
    tahaelearner, Feb 23, 2011 IP