gpt4 book ai didi

php - 邮件程序错误 : SMTP Error: The following SMTP Error: Data not accepted

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:57:24 24 4
gpt4 key购买 nike

下面的代码给出了消息

Mailer Error: SMTP Error: The following SMTP Error: Data not accepted. But when I replace $EmailAdd with a a@yahoo.com. The mail was sent.

我的代码有什么问题?我是 php 的新手,尤其是在处理邮件功能方面。

$sql1 = "SELECT Email_Address FROM participantable where IDno=$studId";
$result1 = mysql_query($sql1);
while ($row1 = mysql_fetch_assoc($result1)){
$EmailADD = $row1["Email_Address"];
}

//error_reporting(E_ALL);
error_reporting(E_STRICT);
date_default_timezone_set('America/Toronto');

include("class.phpmailer.php");
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer();
$body = $mail->getFile('contents.html');
$body = eregi_replace("[\]",'',$body);

$mail->IsSMTP();
$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 = "jsbadiola@gmail.com"; // GMAIL username
$mail->Password = "********"; // GMAIL password
$mail->AddReplyTo("jsbadiola@gmail.com","Lord Skyhawk");
$mail->From = "jsbadiola@gmail.com";
$mail->FromName = "Update";
$mail->Subject = "PHPMailer Test Subject via gmail";
$mail->Body = "Hi,<br>This is the HTML BODY<br>"; //HTML Body
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($body);
$mail->AddAddress($EmailADD, "Agta ka");
$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
$status = "Successfully Save!";
header("location: User_retsched.php?IDno=$studId&status=$status&Lname=$Lname&Fname=$Fname&Course=$Course&Year=$Year");
}

最佳答案

大多数时候我看到这条消息,电子邮件无论如何都会成功发送,但并非总是如此。要调试,请设置:

$mail->SMTPDebug = true;

您可以回显调试消息或使用 error_log() 记录它们:

// 'echo' or 'error_log'
$mail->Debugoutput = 'echo';

一个可能的候选者,尤其是在负载很重的服务器上,是 SMTP 超时:

// default is 10
$mail->Timeout = 60;

class.smtp.php 还有一个 Timelimit 属性用于从服务器读取。

关于php - 邮件程序错误 : SMTP Error: The following SMTP Error: Data not accepted,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/640598/

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