in reply to Fast dispatch of e-mails

Instead of sending mail directly from my web app, I insert the message into a table in my database, and then use a cron job to pick up the new messages and to send them. This makes your web app more responsive.

I have no experience of Mail::Sendmail, but it looks fairly flimsy in comparison with MIME::Lite, which is my mail module of choice and has served me well.

You don't mention what platform you're running this on, but if it is a *nix box, then you should have sendmail available to you. MIME::Lite will use sendmail to inject the mail directly into your local SMTP queue, which is fast. If not, then MIME::Lite will use Net::SMTP to send to a remote SMTP server. This will make your process slower, but if it is not happening in your web app, that's probably OK.

Clint

Replies are listed 'Best First'.
Re^2: Fast dispatch of e-mails
by tirwhan (Abbot) on Jul 06, 2007 at 14:31 UTC

    Sorry clinton, but this is really bad advice. Using MIME::Lite to run an instance of sendmail (or another MTA aliased to it) for every mail you send is far less efficent than having your app talk to a locally running MTA and send the message normally via SMTP. The overhead of starting up a new process for every message far outweighs the minimal network overhead you incur when talking to a running daemon (especiall, since on sane *NIXes the loopback address is special and hardly involves any network overhead at all).

    So my advice would be exactly the opposite, don't pipe the message to a newly started process (which is what MIME::Lite does by default), rather send it via your local mail server installation (which is what Mail::Sendmail does by default).

    Also, by inserting your message into a database and picking it up via cron you are in effect creating your own primitive version of a mail server queue. This is extremely unlikely to be as efficient and failsafe as the queueing system of the MTA, since those have been designed and improved expressly for this purpose for a number of years now.

    All of this is only true if you can run a local mail server of course (which should be possible for any serious web application).


    All dogma is stupid.
      thanks tirwhan - good points well made. I will be revising my strategy.

      Clint