Thread: timeout?

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    15
    Rep Power
    0
    i heave a mailing list with just over 700 people on it. on page one i have a form for newsletter to be typed in, then the person submits the form and the next page has the php to send out the newsletter to all the email addresses in the database.

    my problem is that the page times out and an connection error occurs, so i don't think everyone in the list gets emailed. how do i get around this problem?

    thanks in advance...
  2. #2
  3. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    England, UK
    Posts
    83
    Rep Power
    14
    I don't know what is on your second page but this is how I do my mailing list:

    The first page contains a form:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <form action="http://www.musicgoeson.com/admin/mailinglist/send.php" method="GET">
    <b>Subject:</b><br><input type=text name="subject" size="88" value=""><br>
    <b>Message:</b><br><textarea name="message" rows="15" cols="76"></textarea><br><br>
    <input type="submit" value="Submit" align="absmiddle">
    </form>
    [/code]

    send.php contains...

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?

    $email = "webmaster@musicgoeson.com";

    mysql_connect ("localhost", "user", "pass");
    mysql_select_db(database);

    $query = "SELECT * FROM mailinglist";
    $result = mysql_query($query);

    while ($rega = mysql_fetch_array($result)) {
    mail($rega["email"],
    $subject,
    "$message n
    -------------------------------------------------
    To unsubscribe from the MusicGoesOn.com Mailing List go ton <A HREF="http://www.musicgoeson.com/mailinglist/unsubscribe.php?id=".$rega["id"]," TARGET=_blank>http://www.musicgoeson.com/mailinglist/unsubscribe.php?id=".$rega["id"],</A>
    "From: $emailnReply-To:$emailnX-mailer:PHP/". phpversion());
    }
    mysql_free_result($result);

    ?>
    [/code]

    This pulls the e-mail addresses from a mySQL table (mailinglist) which has two columns: id and email.

    Unfortunately I don't have 700 people on my list so I don't know if this will work for you.

    Let me know

    Thanks

    ------------------
    Girish Gupta
    MusicGoesOn.com
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    15
    Rep Power
    0
    my script is pretty much the same except for the part in mail():

    X-mailer:PHP/". phpversion()

    what does ths line do? thanks again
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Melbourne, Victoria, Australia
    Posts
    104
    Rep Power
    14
    That X-Mailer bit is just a mail header.. it's going to have no effect on the issue of your script timing out.

    Perhaps you should pipe directly to sendmail or something instead of using mail() - I think mail() is sending the mail while you wait, that's why it's timing out. If you can pipe to sendmail or something like that so the mail can be put in a queue instead of being sent while you wait you won't have that trouble.

    Still it wouldn't hurt to extend your maximum script execution time in your php.ini if you can't work around it - just for now.

    Hope that helps,

    Josh
  8. #5
  9. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    Just use te following:

    $pref_limit = ini_get("max_execution_time")
    set_time_limit(120); //2 minuts should be
    enough eey.

    //mail sending stuff

    set_time_limit($pref_limit);
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    15
    Rep Power
    0
    lewi, will this stop the browser from aborting the calls based on its error to connect?

    thanks again
  12. #7
  13. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    61
    You can instruct PHP not to abort the script when the browser disconnects. That way, even if the job is 5 minutes long, you can start it from the browser, and go on your way.
    http://www.php.net/manual/features.c...n-handling.php (see the 'ignore_user_abort()' function).
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    15
    Rep Power
    0
    i'm not sur how to use the ignore_user_abort() function. do you just add it at the beggining of the script? like...

    ignore_user_abort(true);

    // rest of the mailing script goes here

    again, thanks...i'm almost there

Similar Threads

  1. using session timeout without cookies
    By me_helper in forum PHP Development
    Replies: 6
    Last Post: July 27th, 2006, 02:45 AM
  2. Replies: 1
    Last Post: August 22nd, 2003, 03:32 PM
  3. fsockopen timeout problem
    By Jason Keeler in forum PHP Development
    Replies: 1
    Last Post: June 22nd, 2003, 11:25 AM
  4. error log - what mistakes should I look for?
    By mano1 in forum MySQL Help
    Replies: 0
    Last Post: January 8th, 2002, 01:14 PM
  5. fsockopen timeout php4.0.6
    By jamesbond2002 in forum PHP Development
    Replies: 1
    Last Post: November 27th, 2001, 05:57 AM

IMN logo majestic logo threadwatch logo seochat tools logo