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

Ok, the site I'm working on needs to be able to send e-mail to users immediately.
Of course, sendmail isn't great to rely on this for, since it kind of spools and sends it out whenever it feels like it.

I know that there are modules that have been created to deal with e-mail, and I really need to install one that always sends e-mail right away, without waiting until it feels it knows that the user waiting for the message is pissed off.
So, help me! (please??)

Replies are listed 'Best First'.
(kudra: rtfm, reformed friar) Re: Faster Then Sendmail
by kudra (Vicar) on Aug 06, 2000 at 00:36 UTC
Re: Faster Then Sendmail
by merlyn (Sage) on Aug 05, 2000 at 20:57 UTC
      I agree with you completely on Net::SMTP, merlyn. However, gaggio posted a module that has some additional functionality that Net::SMTP doesn't directly support.

      All this depends on where you're counting on the SMTP server being located, however. If you're using the local machines, which is the wisest, then this argument holds no water. You can always count on being able to connect to the local SMTP server (as a general rule. Always check return results to be sure!). Additionally, a user may be getting his mail via POP3 or IMAP, because s/he may not have a local SMTP server that you can connect to.

      If you're trying to connect to a SMTP mailserver on a remote network, then unless you know the actual address of the SMTP server, you may not be able to connect to it. The remote network may have an MX record for their SMTP server, since the mail machine may be mail.mynetwork.com, but has a different IP address than user@mynetwork.com.

      To this end, gaggios module uses DNS::Resolver to determine if an MX record exists for that network, and sends mail to the appropriate MX machine.

      I think this idea is really good, although (and no offense, gaggio) I'd really like to see it wrapped around Net::SMTP, instead of code that has had less exposuse to real world server issues.

      --Chris

      e-mail jcwren
        K, jcwren and merlyn, does Net::SMTP send mail like sendmail or retrieve mail from POP accounts and manage an e-mail server??
        Just reading jcwren's post and looking at Net::SMTP's perldoc, it looks for like Net::SMTP is used to actually manage an e-mail server.

        And in this thing that sendmail immediately sends e-mail, could the real reason it takes so long for the e-mail to arrive in the recipient's inbox be because sendmail is being used so much at once?
        I realize that sendmail is opened with a pipe, meaning it can handle a great amount of traffic at one time, but is the process slowed down with many scripts accessing it at the same time?

        Because I also tried using the scripts right now, and the e-mails always arrive faster than I can get to the inbox, but yesterday it would take about 2 hours to arrive.

        I'm trying to tell myself that the more proccesses attempting to use sendmail, the slower it runs, but this can't be true can it?

Re: Faster Then Sendmail
by tiny (Beadle) on Aug 05, 2000 at 21:12 UTC
    Sendmail does send mail immediately. Give it a few seconds at most to process the MX lookups and such, but it never takes very long. All my scripts that email use sendmail directly and when mailing to the localhost it arrives almost instantly.
      It depends on how sendmail is configured on your server. If you have direct access to configure sendmail you can make it send immediately. If not, it is usually configured to queue mail for a specific period of time. I think this is the problem that mt2k is having.
RE: Faster Then Sendmail
by lindex (Friar) on Aug 06, 2000 at 18:18 UTC
    Nothing ever does anything immediately, not even perl ];)
    but I think sendmail is close enough, if not then just write
    a simple sub that uses DNS::Resolver and Net::SMTP
    to send email for you.
    Heh, with perl & Net::SMTP & Net::POP3 & DNS::Resolver & MAIL::Internet
    writing a mail client these days is a breeze :)



    lindex
    /****************************/ jason@gost.net, wh@ckz.org http://jason.gost.net /*****************************/