After looking through many of the mail modules, I've settled on Mail::Sender. I need authenticated SMTP, so that drops out several other options and I don't want to pull in multiple modules manually to get the necessary authenticating done

My problem comes in with using Mail::Sender from within CGI scripts. I copied the exact same code snippet to a command line script and never get the same problem. The problem is simple: for every few emails sent, Mail::Sender fails with a "Service not available, connection not established" error. The culprit-type script is below. Does Mail::Sender change behaviour under CGI, because I have never once got this error from the command line version:

#!c:/perl/bin/perl -w $|++; use strict; use Mail::Sender; $Mail::Sender::NO_X_MAILER = 1; $Mail::Sender::NO_MESSAGE_ID = 1; open my $log, '>>', 'c:/logcmd.log' or die "open failed: $!"; my $email = Mail::Sender->new( { smtp => 'smtp.somewhere.net', auth => 'LOGIN', authid => 'someuser', authpwd => 'somepasswd', on_errors => 'die', debug => $log } ); $email->Open( { from => 'MyName <me@myserver.com>', to => 'TheirName <them@theirserver.com>', subject => 'Some Subject' } ); $email->SendEnc(<<"END_EMAIL"); This is the body of the email message. Yes, that is right. foo bar baz.... blah. END_EMAIL $email->Close(); close $log;

In reply to Mail::Sender connection failing under CGI by Anonymous Monk

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.