3

我正在尝试使用 Perl 发送电子邮件。我的代码在 Yahoo 的 SMTP 服务器上运行良好,但是当我尝试使用另一个 SMTP 服务器(带有自签名 SSL 证书)时,出现以下错误:

无法启动 TLS:由于握手问题,SSL 连接尝试失败错误:14094410:SSL 例程:SSL3_READ_BYTES:sslv3 在 mail2.pl 第 2 行警告握手失败。

我的代码是:

use Net::SMTP::TLS;

my $mailer = new Net::SMTP::TLS(
        'mail.SomeHost.com',
        Hello   =>      'mail.SomeHost.com',
        Port    =>      587,
        User    =>      'info@SomeHost.com',
        Password=>      '123456789'
);

$mailer->mail('info@SomeHost.com');
$mailer->to('info@SomeHost.com');
$mailer->data();
$mailer->datasend("From: info@SomeHost.com\n");
$mailer->datasend("To: info@SomeHost.com\n");
$mailer->datasend("Subject: test\n");
$mailer->datasend("Content-type: text/html\n\n");
$mailer->datasend("\n");
$mailer->datasend("<html><body><p>hi text</p><br></body></html>\n");
$mailer->dataend();
$mailer->quit;

我怎样才能解决这个问题?

结果-MIO::Socket::SSL=debug4

DEBUG: .../IO/Socket/SSL.pm:2537: new ctx 17003088
DEBUG: .../IO/Socket/SSL.pm:1343: start handshake
DEBUG: .../IO/Socket/SSL.pm:553: ssl handshake not started
DEBUG: .../IO/Socket/SSL.pm:589: not using SNI because hostname is unknown
DEBUG: .../IO/Socket/SSL.pm:621: request OCSP stapling
DEBUG: .../IO/Socket/SSL.pm:640: set socket to non-blocking to enforce timeout=5
DEBUG: .../IO/Socket/SSL.pm:653: Net::SSLeay::connect -> -1
DEBUG: .../IO/Socket/SSL.pm:663: ssl handshake in progress
DEBUG: .../IO/Socket/SSL.pm:673: waiting for fd to become ready: SSL wants a read first
DEBUG: .../IO/Socket/SSL.pm:693: socket ready, retrying connect
DEBUG: .../IO/Socket/SSL.pm:653: Net::SSLeay::connect -> 0
DEBUG: .../IO/Socket/SSL.pm:701: connection failed - connect returned 0
DEBUG: .../IO/Socket/SSL.pm:1769: SSL connect attempt failed because of handshake problems

DEBUG: .../IO/Socket/SSL.pm:1774: SSL connect attempt failed because of handshake problems
    error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
DEBUG: .../IO/Socket/SSL.pm:2570: free ctx 17003088 open=17003088
DEBUG: .../IO/Socket/SSL.pm:2575: free ctx 17003088 callback
DEBUG: .../IO/Socket/SSL.pm:2582: OK free ctx 17003088 Couldn't start TLS:
    SSL connect attempt failed because of handshake problems
    error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake
failure  at mail2.pl line 2.
4

0 回答 0