Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Sending mail from mod-perl takes too long

by pcouderc (Monk)
on Aug 24, 2005 at 18:31 UTC ( [id://486327]=perlquestion: print w/replies, xml ) Need Help??

pcouderc has asked for the wisdom of the Perl Monks concerning the following question:

I am using Mail::Sendmail to send a mail from a script under mod-perl in Apache2.

But it appears that the mailing function is fairly long : about 4 second for each mail, so the user find it long.

In fact, it is fully unnecessary to wait for the sending of the mail being completed.

Has a good Monk an idea how to do?

Thank you in advance
Pierre Couderc

2005-08-26 Retitled by Arunbear, as per Monastery guidelines
Original title: 'What mailer to choose?'

  • Comment on Sending mail from mod-perl takes too long

Replies are listed 'Best First'.
Re: Sending mail from mod-perl takes too long
by pbeckingham (Parson) on Aug 24, 2005 at 18:58 UTC

    Well, this mediocre monk says that putting the code that generates the mail and the code that sends it, in a separate process/thread means that one is not dependent on the other.



    pbeckingham - typist, perishable vertebrate.
Re: Sending mail from mod-perl takes too long
by itub (Priest) on Aug 24, 2005 at 19:31 UTC
Re: Sending mail from mod-perl takes too long
by dtr (Scribe) on Aug 24, 2005 at 20:53 UTC

    I think that your best bet would be to do a minor re-design of your application at this point. Rather than sending an email directly, you should be writing a job to a queue (eg by writing to a table in a database). Another job should then run in the background to process that queue (eg from cron) and actually send the messages. This is much more resiliant in case of downtime (eg mailserver maintenance won't take your site down), and won't force your users to wait whilst your application tries to send mail.

    If you don't want to do that though, then the first thing I'd check is whether you're talking to a remote mailserver, or one that's running on the local machine. Talking to a mailserver on the local machine is likely to be a lot faster than talking to a remote machine.

    If that isn't the problem, and you're running sendmail locally, then stopping sendmail trying to do ident queries may also help (confTO_IDENT in your sendmail.mc file), as may checking your /etc/hosts file to make sure you have a proper entry for localhost in there.

Re: Sending mail from mod-perl takes too long
by atcroft (Abbot) on Aug 24, 2005 at 19:38 UTC

    That does sound a bit long. Just out of curiousity, are thoe messages very large? Also, if it is the *exact* same message going to multiple addresses, are you building a new copy of the message for each?

Thank you all monks
by pcouderc (Monk) on Aug 25, 2005 at 07:21 UTC
    All the answers are here, and I have many ways.

    I shall try first the PerlCleanupHandler that I discover thanks to you, and maybe if it is a problem, some system().
    My mails are fairly small.
    Thank you, honorable monks.
      There are libs that go directly to the MTA's queue. One example is for Qmail QmailQueue

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://486327]
Approved by pbeckingham
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (2)
As of 2024-04-20 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found