gpt4 book ai didi

php - 邮件程序错误 : SMTP connect() failed in php mailer( https://github. com/PHPMailer/PHPMailer/wiki/Troubleshooting)

转载 作者:搜寻专家 更新时间:2023-10-31 21:07:10 26 4
gpt4 key购买 nike

<分区>

这是我在网上引用了很多之后从本地主机发送电子邮件的代码。

html 格式:

<form method="post" action="email.php">
Email: <input name="email" id="email" type="text" /><br />

Message:<br />
<textarea name="message" id="message" rows="15" cols="40"></textarea><br />

<input type="submit" value="Submit" />
</form>

电子邮件.php:

<?php

// $email and $message are the data that is being
// posted to this page from our html contact form
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;

require_once('class.phpmailer.php');
require 'PHPMailerAutoload.php';
require 'class.smtp.php';

$mail = new PHPMailer();
$body='hellooooo';
$mail->IsSMTP();

$mail->Host = "ssl://smtp.gmail.com"; // specify main and backup server

$mail->SMTPAuth = true; // turn on SMTP authentication

$mail->Username = "xxxx@gmail.com"; // SMTP username
$mail->Password = "zzz"; // SMTP password
$mailer->SMTPSecure = 'ssl';
$mailer->Port = 465;//587;
$mail->AddAddress("xxx", "xx");
$mail->SetFrom('xxx@gmail.com','xxxx');
$mail->WordWrap = 50;

$mail->IsHTML(true);

$mail->Subject = "You have received feedback from your website!";

$mail->MsgHTML($body);

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

echo "Message has been sent";
?>

所以当我运行我的代码时,它会显示这样的错误,

Message could not be sent.

Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

我从以下文件中删除了 ;extension=php_openssl.dll 行中的分号,然后重新启动 xampp。

c/xampp/apache/bin/php.ini and c/xampp/php/php.ini

还是一样的错误..

注意:我是 php 的新手,但我想特别了解这个问题并解决问题。我在堆栈中提到了类似的问题,但这对我没有帮助,

谁能帮我解决这个问题?

谢谢,

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