gpt4 book ai didi

php - PHPMailer 中的 SMTP connect() 失败错误

转载 作者:可可西里 更新时间:2023-11-01 13:03:34 24 4
gpt4 key购买 nike

<分区>

我是 PHP 的新手,我想使用 PHP 发送邮件。我有一个“联系我们”表格,它将接受联系我的人的电子邮件,因此邮件将发送给我。我正在使用来自 https://github.com/PHPMailer/PHPMailer/tree/master 的 PHPMailer 库以下是我正在使用的代码片段。

<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();

$mail->SMTPSecure = 'tls';

$mail->Host = "resolver1.opendns.com"; // this SMTP server of my machine
//$mail->Host = "208.67.222.222";//ip ; which one to use the resolver1.opendns.com or 208.67.222.222 ???

$mail->From = "xyz@gamil.com;//email id of the person

$mail->AddAddress("datta.dhonde@coreathena.com");//my email id

$mail->Subject = "First PHPMailer Message";
$mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50;

if(!$mail->Send())
{
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
else
{
echo 'Message has been sent.';
}
?>

我收到错误消息“消息未发送。邮件错误:SMTP connect() 失败。”我不明白是什么问题..?$邮件->主机=“”;请评论这代表什么??

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