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.


In reply to Re: Sending mail from mod-perl takes too long by dtr
in thread Sending mail from mod-perl takes too long by pcouderc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.