当前位置:  开发笔记 > 编程语言 > 正文

邮件程序错误:SMTP错误:以下SMTP错误:不接受数据

如何解决《邮件程序错误:SMTP错误:以下SMTP错误:不接受数据》经验,为你挑选了1个好方法。

以下代码给出了该消息

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,
This is the HTML BODY
"; //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"); }

Animism.. 7

大多数时候,我已经看到这封邮件无论如何都成功发送了电子邮件,但并非总是如此.要调试,请设置:

$mail->SMTPDebug = true;

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

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

特别是在负载很重的服务器上,可能的候选者是SMTP超时:

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

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



1> Animism..:

大多数时候,我已经看到这封邮件无论如何都成功发送了电子邮件,但并非总是如此.要调试,请设置:

$mail->SMTPDebug = true;

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

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

特别是在负载很重的服务器上,可能的候选者是SMTP超时:

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

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

推荐阅读
yzh148448
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有