Need to send email via SMTP server that has username and password. Using MIME::Entity which uses smtpsend. The problem is I don't know how to pass the package the username and password. When I omit the "auth" line and use an SMTP server that does not require authentication this works like a charm.
sub sSendEmailMIME {
use Mail::Internet;
use MIME::Entity;
my $retval = 0;
my ($to,$from,$subject,$with,$encoding,$filename) = @_;
if ( my $msg = MIME::Entity->build(From => $from,
To => $to,
Subject => $subject,
Type => 'text/html',
Encoding => "7bit",
Path => "$filename",
Filename => "$filename") ) {
if ( $msg->smtpsend(Host => 'smtp.whatever.net') ) {
$msg->auth ('me@whatever.net','123abc');
$retval = 1;
print "sent\n";
} else {
print "send FAILED: $!\n";
}
}
return $retval;
}
This invariably gives me a "send FAILED" without explanation.
Thanks for your help.
Gary