On DigitalOcean I’ve got a vps running MIAB at box.ezemailserver.com and a “Web App” server on another vps at cherrypc.com.
I want to send emails from the web app using a Perl script.
I’m using the MIAB DNS server for both domain names. With the MIAB server I can send and receive email using my Mac Mini “Mail” app so that’s working great.
I’ve edited a perl script that attempts to authenticate a user and send a simple email from cherrypc.com but it is not passing the auth stage. I get this error:
Error sending email: failed AUTH: Command unknown: 'AUTH’
Anyone have any ideas on what I’m doing wrong?
Here’s the script on the web app server, the mail.log from the MIAB, what the script outputs when run:
test3.pl
#!/usr/bin/perl
use Email::Sender::Simple qw(sendmail);
use Email::Sender::Transport::SMTPS;
use Try::Tiny;
my $transport = Email::Sender::Transport::SMTPS->new(
host => 'box.ezemailserver.com',
ssl => 'starttls',
sasl_username => 'hostmaster@ezemailserver.com',
sasl_password => 'xxxx',
debug => 1, # or 1
);
use Email::Simple::Creator; # or other Email::
my $message = Email::Simple->create(
header => [
From => 'hostmaster@ezemailserver.com',
To => 'bill@secureshopper.com',
Subject => 'cherrypc perl test',
],
body => 'This is the test.',
);
try {
sendmail($message, { transport => $transport });
} catch {
die "Error sending email: $_";
};
MIAB mail.log:
Apr 16 13:17:10 box postfix/submission/smtpd[31729]: connect from cherrypc.com[45.55.229.99]
Apr 16 13:17:10 box postfix/submission/smtpd[31729]: lost connection after EHLO from cherrypc.com[45.55.229.99]
Apr 16 13:17:10 box postfix/submission/smtpd[31729]: disconnect from cherrypc.com[45.55.229.99]
cherrypc.com perl script output
root@cherrypc:/usr/lib/cgi-bin# perl test6.pl
Net::SMTPS>>> Net::SMTPS(0.06)
Net::SMTPS>>> IO::Socket::IP(0.37)
Net::SMTPS>>> IO::Socket(1.38)
Net::SMTPS>>> IO::Handle(1.35)
Net::SMTPS>>> Exporter(5.72)
Net::SMTPS>>> Net::SMTP(3.10)
Net::SMTPS>>> Net::Cmd(3.10)
Net::SMTPS=GLOB(0x33b7958)<<< 220 box.ezemailserver.com ESMTP Hi, I’m a Mail-in-a-Box (Ubuntu/Postfix; see https://mailinabox.email/)
Net::SMTPS=GLOB(0x33b7958)>>> EHLO localhost.localdomain
Net::SMTPS=GLOB(0x33b7958)<<< 250-box.ezemailserver.com
Net::SMTPS=GLOB(0x33b7958)<<< 250-PIPELINING
Net::SMTPS=GLOB(0x33b7958)<<< 250-SIZE 134217728
Net::SMTPS=GLOB(0x33b7958)<<< 250-VRFY
Net::SMTPS=GLOB(0x33b7958)<<< 250-ETRN
Net::SMTPS=GLOB(0x33b7958)<<< 250-STARTTLS
Net::SMTPS=GLOB(0x33b7958)<<< 250-ENHANCEDSTATUSCODES
Net::SMTPS=GLOB(0x33b7958)<<< 250-8BITMIME
Net::SMTPS=GLOB(0x33b7958)<<< 250 DSN
Error sending email: failed AUTH: Command unknown: ‘AUTH’
Trace begun at /usr/local/share/perl/5.22.1/Email/Sender/Transport/SMTPS.pm line 98
Email::Sender::Transport::SMTPS::_throw(‘Email::Sender::Transport::SMTPS=HASH(0x24d8b80)’, ‘failed AUTH’, ‘Net::SMTPS=GLOB(0x33b7958)’) called at /usr/local/share/perl/5.22.1/Email/Sender/Transport/SMTPS.pm line 71
Email::Sender::Transport::SMTPS::_smtp_client(‘Email::Sender::Transport::SMTPS=HASH(0x24d8b80)’) called at /usr/local/share/perl/5.22.1/Email/Sender/Transport/SMTPS.pm line 107
Email::Sender::Transport::SMTPS::send_email(‘Email::Sender::Transport::SMTPS=HASH(0x24d8b80)’, ‘Email::Abstract=ARRAY(0x3023ae0)’, ‘HASH(0x3023ca8)’) called at /usr/local/share/perl/5.22.1/Email/Sender/Role/CommonSending.pm line 45
Email::Sender::Role::CommonSending::try {…} at /usr/share/perl5/Try/Tiny.pm line 92
eval {…} at /usr/share/perl5/Try/Tiny.pm line 83
Try::Tiny::try(‘CODE(0x307b370)’, ‘Try::Tiny::Catch=REF(0x3023d38)’) called at /usr/local/share/perl/5.22.1/Email/Sender/Role/CommonSending.pm line 58
Email::Sender::Role::CommonSending::send(‘Email::Sender::Transport::SMTPS=HASH(0x24d8b80)’, ‘Email::Abstract=ARRAY(0x3023ae0)’, ‘HASH(0x3069a30)’) called at /usr/local/share/perl/5.22.1/Email/Sender/Simple.pm line 119
Email::Sender::Simple::send_email(‘Email::Sender::Simple’, ‘Email::Abstract=ARRAY(0x3023ae0)’, ‘HASH(0x3023cf0)’) called at /usr/local/share/perl/5.22.1/Email/Sender/Role/CommonSending.pm line 45
Email::Sender::Role::CommonSending::try {…} at /usr/share/perl5/Try/Tiny.pm line 92
eval {…} at /usr/share/perl5/Try/Tiny.pm line 83
Try::Tiny::try(‘CODE(0x3023b58)’, ‘Try::Tiny::Catch=REF(0x3005228)’) called at /usr/local/share/perl/5.22.1/Email/Sender/Role/CommonSending.pm line 58
Email::Sender::Role::CommonSending::send(‘Email::Sender::Simple’, ‘Email::Simple=HASH(0x3004f88)’, ‘HASH(0x3004ee0)’) called at /usr/share/perl5/Sub/Exporter/Util.pm line 18
Sub::Exporter::Util::ANON(‘Email::Simple=HASH(0x3004f88)’, ‘HASH(0x3004ee0)’) called at test6.pl line 26
main::try {…} at /usr/share/perl5/Try/Tiny.pm line 92
eval {…} at /usr/share/perl5/Try/Tiny.pm line 83
Try::Tiny::try(‘CODE(0x2fd50b0)’, ‘Try::Tiny::Catch=REF(0x2f96d08)’) called at test6.pl line 29