如何检测拒绝发送 SMTP 响应?
How to detect a refuse to send SMTP response?
我们正在使用 Perl 程序通过 Net::SMTP::SSL
模块发送电子邮件。我们还使用 Google SMTP 服务器。他们每天通过 SMTP 发送 100 封电子邮件的限制(如果您使用的是免费服务)。
有时我们会不小心超过该限制,Google 不会发送电子邮件。但是我们的 Perl 程序似乎没有接受它。有谁知道如何检测发送失败?
我认为这是相关代码:
use Net::SMTP::SSL;
my $smtp;
$smtp = Net::SMTP::SSL->new( 'smtp.gmail.com', Port => 465, Debug => 0 ) or
die "Could not connect to Gmail server!";
$smtp->auth( $L, $P ) or die "Authentication Failed!";
$smtp->mail( $from . "\n" ) or die "Cannot send as user $from!";
$smtp->to( $to . "\n" ) or die "Cannot send to $to!";
$smtp->data();
$smtp->datasend( "MIME-Version: 1.0\n" );
$smtp->datasend( "From: " . $from . "\n" );
$smtp->datasend( "To: " . $to . "\n" );
$smtp->datasend( "Subject: " . $subject . "\n" );
$smtp->datasend( "\n");
$smtp->datasend( $body . "\n" );
$smtp->dataend();
$smtp->quit;
我不知道 google 如何在达到限制时拒绝发送电子邮件,但有几种方法:
- reject mail from or rcpt to commands:在这种情况下,您应该在代码中看到警告
- reject the mail delivery: 在这种情况下
dataend()
应该告诉你问题所在,即发送邮件时应该调用的最后一个方法。但看起来您甚至没有在代码中使用 dataend()
,这可能会导致交付纯属运气。
我们正在使用 Perl 程序通过 Net::SMTP::SSL
模块发送电子邮件。我们还使用 Google SMTP 服务器。他们每天通过 SMTP 发送 100 封电子邮件的限制(如果您使用的是免费服务)。
有时我们会不小心超过该限制,Google 不会发送电子邮件。但是我们的 Perl 程序似乎没有接受它。有谁知道如何检测发送失败?
我认为这是相关代码:
use Net::SMTP::SSL;
my $smtp;
$smtp = Net::SMTP::SSL->new( 'smtp.gmail.com', Port => 465, Debug => 0 ) or
die "Could not connect to Gmail server!";
$smtp->auth( $L, $P ) or die "Authentication Failed!";
$smtp->mail( $from . "\n" ) or die "Cannot send as user $from!";
$smtp->to( $to . "\n" ) or die "Cannot send to $to!";
$smtp->data();
$smtp->datasend( "MIME-Version: 1.0\n" );
$smtp->datasend( "From: " . $from . "\n" );
$smtp->datasend( "To: " . $to . "\n" );
$smtp->datasend( "Subject: " . $subject . "\n" );
$smtp->datasend( "\n");
$smtp->datasend( $body . "\n" );
$smtp->dataend();
$smtp->quit;
我不知道 google 如何在达到限制时拒绝发送电子邮件,但有几种方法:
- reject mail from or rcpt to commands:在这种情况下,您应该在代码中看到警告
- reject the mail delivery: 在这种情况下
dataend()
应该告诉你问题所在,即发送邮件时应该调用的最后一个方法。但看起来您甚至没有在代码中使用dataend()
,这可能会导致交付纯属运气。