Sendmail with Perl uses localhost.localdomain
instead of a fully qualified domain name (FQDN). Sendmail and server configuration is correct, hostname is setup with FQDN.
My script contains the following lines:
use MIME::Lite;
use Email::Sender::Simple qw /sendmail/;
use Email::Sender::Transport::SMTPS;
...
my $transport = Email::Sender::Transport::SMTPS->new({
host => $server,
ssl => 'starttls',
port => $port,
sasl_username => $user,
sasl_password => $password,
debug => 1,
});
sendmail($msg->as_string, { transport => $transport });
Mail is sent successfully, however sendmail
use localhost.localdomain
instead of FQDN with EHLO
. Debug information shows:
Net::SMTPS>>> Net::SMTPS(0.09)
Net::SMTPS>>> IO::Socket::IP(0.39)
Net::SMTPS>>> IO::Socket(1.40)
Net::SMTPS>>> IO::Handle(1.40)
Net::SMTPS>>> Exporter(5.73)
Net::SMTPS>>> Net::SMTP(3.11)
Net::SMTPS>>> Net::Cmd(3.11)
Net::SMTPS=GLOB(0x2903e48)<<< 220 smtp.gmail.com ESMTP l186sm18879092ioa.54 - gsmtp
Net::SMTPS=GLOB(0x2903e48)>>> EHLO localhost.localdomain
Net::SMTPS=GLOB(0x2903e48)<<< 250-smtp.gmail.com at your service, [masked IP address]
Net::SMTPS=GLOB(0x2903e48)<<< 250-SIZE 35882577
Net::SMTPS=GLOB(0x2903e48)<<< 250-8BITMIME
Net::SMTPS=GLOB(0x2903e48)<<< 250-STARTTLS
Net::SMTPS=GLOB(0x2903e48)<<< 250-ENHANCEDSTATUSCODES
Net::SMTPS=GLOB(0x2903e48)<<< 250-PIPELINING
Net::SMTPS=GLOB(0x2903e48)<<< 250-CHUNKING
Net::SMTPS=GLOB(0x2903e48)<<< 250 SMTPUTF8
Net::SMTPS=GLOB(0x2903e48)>>> STARTTLS
Net::SMTPS=GLOB(0x2903e48)<<< 220 2.0.0 Ready to start TLS
Net::SMTPS=GLOB(0x2903e48)>>> EHLO localhost.localdomain
Net::SMTPS=GLOB(0x2903e48)<<< 250-smtp.gmail.com at your service, [masked IP address]
Net::SMTPS=GLOB(0x2903e48)<<< 250-SIZE 35882577
Net::SMTPS=GLOB(0x2903e48)<<< 250-8BITMIME
Net::SMTPS=GLOB(0x2903e48)<<< 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
Net::SMTPS=GLOB(0x2903e48)<<< 250-ENHANCEDSTATUSCODES
Net::SMTPS=GLOB(0x2903e48)<<< 250-PIPELINING
Net::SMTPS=GLOB(0x2903e48)<<< 250-CHUNKING
Net::SMTPS=GLOB(0x2903e48)<<< 250 SMTPUTF8
When sendmail
is used from the console directly (not using Perl), correct FQDN is used with EHLO
.
Net::SMTPS=GLOB(0x2903e48)>>> EHLO localhost.localdomain
From the documentation of Email::Sender::Transport::SMTPS:
ATTRIBUTES
The following attributes may be passed to the constructor:
...
helo: what to say when saying HELO; no default
If nothing is given in helo
the default from the underlying packet (Net::SMTPS) is used, which is localhost.localdomain
. To use something different just do
my $transport = Email::Sender::Transport::SMTPS->new({
...,
helo => 'whatever.you.want.to.use.instead.of.localhost.localdomain'
});