Email server timing out in email script

Discussion in 'Perl' started by John Silver, Feb 4, 2005.

  1. John Silver

    John Silver Guest

    I have a perl script running on machine A, a web server. A visitor
    completes certain pieces of data and these are compiled into two emails, one
    addressed to the visitor and copied to the site owner, the other addressed
    to the webmaster and including cookie and timing data for debugging.

    The email is sent by machine B which is the email server for the domain.
    Here are some config values for the perl script, names have been changed to
    protect the innocent.

    my $smtp_server = "pennyblack";
    my $smtp_domain = "fred.fred.fred.fred";
    my $MailFrom = "domain\@fred.fred.fred";
    my $MailTo = "owner\@fred.fred.fred";

    The opening part of the perl script is as follows:

    sub psendmail()

    use Net::SMTP;

    # connect to an SMTP server
    $smtp = Net::SMTP->new( $smtp_server, Hello => $smtp_domain, Timeout =>
    10, Debug => 1);
    if ( !$smtp ) { return 1; }
    die "Couldn't connect psendmail to email server" unless $smtp;

    $smtp->mail( $MailFrom); # use the sender's real address here
    $smtp->to( $MailTo); # recipient's real address
    $smtp->data(); # Start the mail

    # Send the header.
    $smtp->datasend("To: $MailTo\n"); # address in the email view
    $smtp->datasend("From: $MailFrom\n"); #address in the email view

    And here is the end of the process.

    $smtp->dataend(); # Finish sending the mail
    $smtp->quit; # Close the SMTP connection

    return 0;

    The email server is being opened in debug while I fix some issues, and the
    short timeout is because of the following messages in the log, which had
    been around 2 minutes each prior to my changing them.

    Net::SMTP>>> Net::Cmd(2.24)
    Net::SMTP>>> Exporter(5.57)
    Net::SMTP>>> IO::Socket::INET(1.27)
    Net::SMTP>>> IO::Socket(1.28)
    Net::SMTP>>> IO::Handle(1.23)
    Net::SMTP=GLOB(0x1ab6c08)<<< 220 fred.fred.fred.fred ESMTP MailEnable
    Service, Version: 0-1.17- ready at 02/04/05 18:14:25
    Net::SMTP=GLOB(0x1ab6c08)>>> EHLO fred.fred.fred.fred
    Net::SMTP=GLOB(0x1ab6c08)<<< 250-fred.fred.fred.fred [], this
    server offers 4 extensions
    Net::SMTP=GLOB(0x1ab6c08)<<< 250-AUTH LOGIN
    Net::SMTP=GLOB(0x1ab6c08)<<< 250-SIZE 5120000
    Net::SMTP=GLOB(0x1ab6c08)<<< 250-HELP
    Net::SMTP=GLOB(0x1ab6c08)<<< 250 AUTH=LOGIN
    Net::SMTP=GLOB(0x1ab6c08)>>> MAIL FROM:
    Net::SMTP=GLOB(0x1ab6c08)<<< 250 Requested mail action okay, completed
    Net::SMTP=GLOB(0x1ab6c08)>>> RCPT TO: [Fri Feb 4 18:14:36 2005]
    Net::SMTP=GLOB(0x1ab6c08): Timeout at C:/ .. obfuscated path ..
    /cgi-bin/applymail.cgi line 210
    Net::SMTP=GLOB(0x1ab6c08)>>> DATA [Fri Feb 4 18:14:46 2005] applymail.cgi:
    Net::SMTP=GLOB(0x1ab6c08): Timeout at C:/ .. obfuscated path ..
    /cgi-bin/applymail.cgi line 211
    Net::SMTP=GLOB(0x1ab6c08)>>> To:
    Net::SMTP=GLOB(0x1ab6c08)>>> From:

    The email is being delivered, and where I have used a CC: definition on the
    email to an external email service, this too has worked. This suggests the
    email server is doing its job, yet the closure of the message also suggests
    there is an issue. I need, at the very least, to get the time down for this
    process, four timeouts on each of two mail sends means the script is taking
    more than 80 seconds to run, and most of that is timeout.

    Following is the closure part of the log. My apparently valid statements
    above are also causing issues. There are no errors in any [part of the data

    Net::SMTP=GLOB(0x1ab6c08)>>> . [Fri Feb 4 18:14:56 2005] applymail.cgi:
    Net::SMTP=GLOB(0x1ab6c08): Timeout at C:/ .. obfuscated path ..
    /cgi-bin/applymail.cgi line 262
    Net::SMTP=GLOB(0x1ab6c08)>>> QUIT [Fri Feb 4 18:15:06 2005] applymail.cgi:
    Net::SMTP=GLOB(0x1ab6c08): Timeout at C:/ .. obfuscated path ..
    /cgi-bin/applymail.cgi line 263

    Kind regards

    John Silver, Feb 4, 2005
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rtm
  2. Mark
    Natty Gur
    Jul 8, 2003
  3. =?Utf-8?B?VGVqYXN3aQ==?=

    ASP.NET SQL Server Session not timing out

    =?Utf-8?B?VGVqYXN3aQ==?=, Feb 11, 2005, in forum: ASP .Net
    Feb 12, 2005
  4. sunkrajesh
    May 31, 2009
  5. Gary