gpt4 book ai didi

即使未启用加密,PHPMailer 也会使用 TLS 发送

转载 作者:可可西里 更新时间:2023-11-01 12:25:19 24 4
gpt4 key购买 nike

我正在尝试使用没有 TLS 的 PHPMailer 发送电子邮件,但 PHPMailer 仍然尝试使用 TLS 发送电子邮件,即使我没有启用它:

include_once("PHPMailer-master\PHPMailerAutoload.php");

$To = 'some@site.com';
$Subject = 'Topic';
$Message = 'msg test';

$Host = 'site.com.br';
$Username = 'contact@site.com.br';
$Password = 'pass';
$Port = "587";

$mail = new PHPMailer();
$body = $Message;
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = $Host; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
//$mail->SMTPSecure = 'ssl'; //or tsl -> switched off
$mail->Port = $Port; // set the SMTP port for the service server
$mail->Username = $Username; // account username
$mail->Password = $Password; // account password

$mail->SetFrom($Username);
$mail->Subject = $Subject;
$mail->MsgHTML($Message);
$mail->AddAddress($To);

if(!$mail->Send()) {
$mensagemRetorno = 'Error: '. print($mail->ErrorInfo);
echo $mensagemRetorno;
} else {
$mensagemRetorno = 'E-mail sent!';
echo $mensagemRetorno;
}

发送邮件后,我收到了这条消息:

2016-09-01 21:08:55 CLIENT -> SERVER: EHLO www.johnmendes.com.br
2016-09-01 21:08:55 CLIENT -> SERVER: STARTTLS
2016-09-01 21:08:55 SMTP ERROR: STARTTLS command failed: 454 TLS not available due to temporary reason
2016-09-01 21:08:55 SMTP Error: Could not connect to SMTP host.
2016-09-01 21:08:55 CLIENT -> SERVER: QUIT
2016-09-01 21:08:55 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Erro ao enviar e-mail: 1

服务器不支持 ssl 或 tls。

有什么想法吗?

最佳答案

这在 PHPMailer 文档中有所介绍。 PHPMailer 执行机会性 TLS - 如果服务器宣传它可以执行 TLS(您的服务器执行),它将自动使用它而无需您询问。您可以禁用此功能:

$mail->SMTPSecure = false;
$mail->SMTPAutoTLS = false;

从错误消息来看,这似乎是您的托管服务提供商的暂时性问题。如果设置 $mail->SMTPDebug = 2;,您会看到更多信息。

我可以看到你的代码基于一个过时的例子,所以确保你有 the latest version of PHPMailer并将您的代码基于随附的示例。

关于即使未启用加密,PHPMailer 也会使用 TLS 发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39280938/

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