I have a Perl script for sending Emails:
#!/usr/bin/perl
use strict;
use warnings;
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTP ();
use Email::Simple ();
use Email::Simple::Creator ();
my $smtpserver = 'server.com';
my $smtpport = 2525;
my $smtpuser = 'test@server.com';
my $smtppassword = 'secret';
my $transport = Email::Sender::Transport::SMTP->new({
host => $smtpserver,
port => $smtpport,
sasl_username => $smtpuser,
sasl_password => $smtppassword,
debug => 1,
});
my $email = Email::Simple->create(
header => [
To => 'myself@gmail.com',
From => "User name <$smtpuser>",
Subject => 'Hello',
],
body => "This is my message\n",
);
sendmail($email, { transport => $transport });
It works on one server. But on another the script freezes. Debug messages are:
Net::SMTP>>> Net::SMTP(2.31)
Net::SMTP>>> Net::Cmd(2.29)
Net::SMTP>>> Exporter(5.63)
Net::SMTP>>> IO::Socket::INET(1.31)
Net::SMTP>>> IO::Socket(1.31)
Net::SMTP>>> IO::Handle(1.28)
What's wrong? How to debug?
This happens if the TCP connection to the server was successfully established but the server does not send the expected SMTP greeting back. This can have several reasons, like:
I would suggest you look at the configuration of the server to see what is actually is expected.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.