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;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.