1

带有 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.

4

1 回答 1

2
Net::SMTPS=GLOB(0x2903e48)>>> EHLO localhost.localdomain

来自Email::Sender::Transport::SMTPS 的文档

属性
以下属性可以传递给构造函数:
...
helo:说 HELO 时要说什么;无默认

helo如果底层数据包 (Net::SMTPS) 的默认值没有给出任何内容,则使用localhost.localdomain. 要使用不同的东西,只需做

my $transport = Email::Sender::Transport::SMTPS->new({
    ...,
    helo => 'whatever.you.want.to.use.instead.of.localhost.localdomain'
});
于 2019-09-07T17:27:00.073 回答