gpt4 book ai didi

email - PHPMailer 因 ssl 而失败

转载 作者:太空宇宙 更新时间:2023-11-03 15:08:30 26 4
gpt4 key购买 nike

我在通过启用了 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

最佳答案

截至今天@PHPMailer 版本 6.1.4这些对我有用:-

    $email->SMTPDebug = SMTP::DEBUG_SERVER; 
$email->isSMTP();
$email->Host = 'host';
$email->SMTPAuth = true;
$email->Username = 'username';
$email->Password = 'password';
$email->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$email->Port = 465;

关于email - PHPMailer 因 ssl 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35596504/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com