May I recommend Net::SMTP. Here's a piece of code that has
been reliable since this time last year.
Its very easy to understand.
sub vianetsmtp
{
my $from = $_[0];
my $to = $_[1];
my $subject = $_[2];
my $body = $_[3];
$smtp = Net::SMTP->new ($maileroutrelay,
Timeout => $mailerouttimeout,
Debug => $maileroutdebug
) or logtofile ($logdir.'/usermailer',"can't create
+new smtp mail object");
defined ($smtp) or die;
my $domainmessg = $smtp->domain;
my $bannermessg = $smtp->banner;
$smtp->mail($from);
$smtp->to($to);
$smtp->data;
$smtp->datasend("from:$from");
$smtp->datasend("\n");
$smtp->datasend("subject:$subject");
$smtp->datasend("\n");
$smtp->datasend("$body");
$smtp->datasend("\n");
$smtp->quit;
undef $smtp;
logtofile ($logdir.'/usermailer',"usermailer: mail written via net::sm
+tp");
return 1;
}
The extra defined getout is probably redundant, but I know better than to mess with working code :)
Most mail problems are to do with routing ime, half the time its getting out but not being routed. If you use a direct method like above you can send to the destination mailserver in one.