我在通过SMTP发送带有PHPmailer的邮件时遇到问题。
邮件在5秒钟后发出,但它仍然提示我错误:
SMTP -> ERROR: DATA not accepted from server
但邮件被发送,但是5秒后,我相信它与来自
的一行有关class.phpmailer.php
public $Timeout = 5;
因为当我将此设置为10秒时,它会等待10秒......
问题是当我尝试在body html中添加锚超链接时,例如,如果我尝试发送
<a>nonlink</a> <br> <b>bold text</b>
它发送邮件没有问题,html代码很好,但是当我发送
<a href="http://www.google.com">nonlink</a> <br> <b>bold text</b>
它给了我那个错误......
我的发送代码是:
/*SEND MAIL*/
//error_reporting(E_ALL);
//error_reporting(E_STRICT);
error_reporting(0);
date_default_timezone_set('America/Toronto');
require_once('../../library/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$Link = '<a href="http://www.google.com">Confirm user</a>';
$body = $Link;
/*$body = eregi_replace("[\]",'',$body);*/
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtpout.europe.secureserver.net"; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "smtpout.europe.secureserver.net"; // sets the SMTP server
$mail->Port = 80; // set the SMTP port for the GMAIL server
$mail->Username = "contact@mysite.com"; // SMTP account username
$mail->Password = "thesecredpassword"; // SMTP account password
$mail->SetFrom('contact@mysite.com"', 'The name');
$mail->Subject = "Account Confirmation";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$address = $Username;
$mail->AddAddress($address, $Name);
if(!$mail->Send())
{
/*echo "Mailer Error: " . $mail->ErrorInfo;*/
$error = true;
$MailHasBeenNotSended = true;
}