带有 Perl 的 Sendmail 使用localhost.localdomain
而不是完全限定的域名 (FQDN)。Sendmail 和服务器配置正确,主机名设置为 FQDN。
我的脚本包含以下几行:
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 });
邮件已成功发送,但sendmail
使用.localhost.localdomain
而不是 FQDN EHLO
。调试信息显示:
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
当sendmail
直接从控制台使用(不使用 Perl)时,正确的 FQDN 与EHLO
.