ErrorInfo; 实际上,如果一切正常,页-6ren">
gpt4 book ai didi

PhpMailer:加载一段时间然后 ERR_EMPTY_RESPONSE

转载 作者:行者123 更新时间:2023-12-04 19:18:18 24 4
gpt4 key购买 nike

我正在处理一些奇怪的事情..我正在设置 phpmailer,如果出现错误,我通常会得到错误

echo "Mailer Error: " . $mail->ErrorInfo;

实际上,如果一切正常,页面会加载一段时间然后停止加载,在 chrome 中出现错误:ERR_EMPTY_RESPONSE(无法加载页面,因为服务器未加载数据)

这是内容

<?php

$mail = new PHPMailer();

// set mailer to use SMTP
$mail->IsSMTP();

$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 645;
$mail->SMTPAuth = true; // turn on SMTP authentication

$mail->Username = "myemail@gmail.com"; // SMTP username
$mail->Password = "my password"; // SMTP password

$email = 'myemail@gmail.com';
$mail->From = $email;

$mail->AddAddress("to@example.com", "Name");

$mail->WordWrap = 50;
$mail->IsHTML(true);

$mail->Subject = "Subject of the mail";

$mail->Body = "content";
$mail->AltBody = "content";

if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}

echo "Message has been sent";
?>

当然我已经包含了这些文件:

require_once('../library/class.phpmailer.php');
require_once('../library/PHPMailerAutoload.php');

最佳答案

两个错误 - 只需加载自动加载器,它会为您加载类,这就是您所需要的。

您已设置Port = 645;我怀疑你的意思是 465。

对于 gmail,您应该遵循 the example from the docs : 使用 Port = 587SMTPSecure = 'tls'

关于PhpMailer:加载一段时间然后 ERR_EMPTY_RESPONSE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28729766/

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