Re: mail function

From: Manuel Lemos (mlemos_at_acm.org)
Date: 08/05/04

  • Next message: Tony Marston: "Re: Bad php behaviour with related paths"
    Date: Thu, 05 Aug 2004 16:25:36 -0300
    
    

    Hello,

    On 08/05/2004 08:03 AM, AJ wrote:
    > I've got a little newsletter system that I put together for one of my
    > customers. Basically, it's a table with firstname, lastname and e-mail
    > address.
    >
    > The script then goes through the database, line by line, and sends out a
    > personalised e-mail to the recipient. At the moment, the table is about
    > 1500 odd recrods. When I did the send for the first time, this probably
    > took around 30 minutes to run. Once you click on the send button, it then
    > sits there as if it's trying to load a HUGE page for 30 minutes and then
    > comes back with a message to say that it was successful.

    You need to tune your delivery method for bulk delivery. Doing that
    depends on which mail system do you use.

    The time you are taking (1.5 seconds per message) suggests that your
    mail system is attempting to deliver the messages immediately. For bulk
    mailing, its is much faster to just tell the mailer to queue the
    messages and deliver them later.

    You may want to take a look at this class and its documentation that
    gives you tips of how to optimize the delivery for bulk mailing.

    For what you are doing I achieve rates of 20 messages per second using
    this class.

    If you are using sendmail, there is a spealized sub-class that let you
    queue the messages instead of deliverying them. Other methods have their
    own sub-classes with options to tune them for bulk mailing.

    http://www.phpclasses.org/mimemessage

    This class also lets you specify a return path address independently of
    the delivery method. In that address you should receive the bounced
    messages.

    Those messages should be processed to figure the address that is
    bouncing. You should remove or flag that address to avoid sending
    messages to it in the future because bouncing messages often make your
    mail server choke.

    I usually make the messages bounce to a mail box accessible with POP3.
    Then I poll that mailbox periodically to processed the bounced messages.

    http://www.phpclasses.org/pop3class

    > This worked but I'm wondering if there is a theoretical limit to the amount
    > of time that the browser will wait before it times out. I'm guessing that
    > it would send out as many e-mails as it had reached and no more. I'm also
    > guessing that whilst the script is running then the browser is still
    > receiving data which is why it was prepared to wait as long as it did.
    >
    > Is there a better way of doing this?

    Yes, as others suggested, this is a task to run from a standalone script
    executed off the Web server with PHP CLI/CGI version. I usually start
    this from a script run with cron under Linux.

    -- 
    Regards,
    Manuel Lemos
    PHP Classes - Free ready to use OOP components written in PHP
    http://www.phpclasses.org/
    PHP Reviews - Reviews of PHP books and other products
    http://www.phpclasses.org/reviews/
    Metastorage - Data object relational mapping layer generator
    http://www.meta-language.net/metastorage.html
    

  • Next message: Tony Marston: "Re: Bad php behaviour with related paths"