我在通过启用了 ssl 的 SMTP 使用 PHPMailer 发送电子邮件时遇到问题。
$mail = new PHPMailer;
// HTML email!
$mail->IsHTML(true);
$mail->isSMTP();
$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = "server.co.tz";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 465;
$mail->SMTPSecure = "ssl";
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = "xxxxxxx";
//Password to use for SMTP authentication
$mail->Password = "yyyyyyy";
当我运行脚本时,出现以下错误:
Mailer Error: SMTP connect() failed.
在 exim4 日志中:
2016-02-24 11:02:20 TLS error on connection from [197.215.254.114] (gnutls_handshake): A TLS fatal alert has been received.
我不知道这里出了什么问题。
我为我的电子邮件客户端定期使用 SMTP,并且 SSL 证书是有效的。
更新:
获得最新版本并将调试设置为 3,但仍然没有运气:
Connection: opening to ssl://fsm.co.tz:465, timeout=300, options=array ()
SMTP ERROR: Failed to connect to server: (0)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting