gpt4 book ai didi

php - 关于在 php 中发送邮件的 fsockopen() 错误

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

我想在用户注册后向用户发送确认电子邮件。我正在使用 xampp。当我运行我的 php 文件时,它返回以下错误:

    Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\xampp\htdocs\class.smtp.php on line 122

Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\xampp\htdocs\class.smtp.php on line 122
Message has not been sent.

我的 php 文件中的相关部分:

try
{
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->SMTPSecure = "ssl";
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->CharSet="utf-8";
$mail->Username = "user@gmail.com";
$mail->Password = "password";
$mail->From = "user@gmail.com";
$mail->FromName="DBE Yazılım";
$mail->AddAddress($_POST['UserMail']);
$mail->Subject = "Registration Information";
$mail->Body = "Hello your password is " . $userpass;
//$mail->AddAttachment($path);
$mail->Send();
if($mail->Send())
echo 'Message has been sent.';
else
echo 'Message has not been sent.';
}
catch(Exception $e)
{
echo 'hata'.$e->getMessage();
}

我看过论坛,这个错误通常是关于 ssl 的。他们说 extension=php_openssl.dll 必须添加到 php.ini 中。我添加了这部分,但没有任何改变。这是关于xampp的吗?

提前致谢。

最佳答案

如您在错误消息中所见

unable to connect to ssl://ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\xampp\htdocs\class.smtp.php on line 122

ssl:// 太多了

$mail->Host = "smtp.gmail.com"; // instead of ssl://smtp.gmail.com

通常,如果您看到术语“主机”,这实际上意味着“主机”而不是 url

关于php - 关于在 php 中发送邮件的 fsockopen() 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11540333/

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