gpt4 book ai didi

php - SMTP Gmail 服务器 SSL 错误

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

我使用此编码通过 gmail 发送邮件,但出现以下错误,在这里,当我删除 ssl 部分时,它可以正常工作,但我无法收到任何电子邮件(也在垃圾邮件中检查过)。还有其他问题吗?

$mail = new phpmailer;
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug = 1;// enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "un"; // GMAIL username
$mail->Password = "pwd"; // GMAIL password
$mail->SetFrom('test@gmail.com', 'Bharanidharan');
$mail->AddReplyTo("test@gmail.com","Vishal Kumar");
$mail->AddAddress("test@gmail.com","Bharani");
$mail->Subject = "Hey, check out";
$body = "hey, check email";
$mail->MsgHTML($body);
$address = "test@gmail.com";
$mail->AddAddress($address, "test");
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent";
}

最佳答案

在 Apache 中启用 mod_ssl(搜索配置文件)和 openssl PHP 扩展(检查 php.ini)

关于php - SMTP Gmail 服务器 SSL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8668744/

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