gpt4 book ai didi

PHPMailer错误连接: opening to ssl://smtp. gmail.com :465,超时=300,选项=数组()

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

您好,我正在尝试使用 PHPMailer,它无法正常工作,给我错误

Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array ()

这是我的代码

     require_once('mailFiles/PHPMailerAutoload.php');
echo (extension_loaded('openssl')?'SSL loaded':'SSL not loaded')."<br/>";
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPDebug = 4;
$mail->Debugoutput = 'html';
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
// $mail->SMTPSecure = 'tls';
$mail->Host = 'smtp.gmail.com';
// $mail->Host = gethostbyname('smtp.gmail.com');
// $mail->Host = 'tls://smtp.gmail.com:587';
// $mail->Port = 587;
$mail->Port = 465;
$mail->Username = "xs4arabiabahrain@gmail.com";
$mail->Password = "mailpass";
$mail->setFrom('mail@gmail.com', 'Firstz Last');
$mail->addAddress('myemail@gmail.com', 'MAAGE-EMAIL User');
$mail->IsHTML(true);

//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML('Hi test 123');
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');
$result = $mail->send();
if (!$result) {
echo ("Mailer Error: ");
echo ($mail->ErrorInfo);
} else {
echo ("Message sent!");
}

累了 tls 仍然没有工作。

最佳答案

问题出在我的防病毒软件上,我使用的是 McAfee,您需要更改其设置,请遵循此 link更改这些设置。我希望它也能帮助其他人。

关于PHPMailer错误连接: opening to ssl://smtp. gmail.com :465,超时=300,选项=数组(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39568267/

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