运行PHP脚本时出现无效的地址错误
当我发送邮件时,我收到错误Invalid address:
但邮件发送成功...
答案 0 :(得分:0)
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: Website Administrator' . "\r\n"
include("Mailer/class.phpmailer.php");
include("Mailer/class.smtp.php");
// note, this is optional - gets called from main class if not already loaded
$mail = new PHPMailer();
$body = $msg ;
$body = @ereg_replace("[\]",'',$body);
$mail->Body = "";
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = 'security'; // sets the prefix to the servier
$mail->Host = 'test.net'; // sets GMAIL as the SMTP server
$mail->Port = '587'; // set the SMTP port
// $mail->SMTPDebug = 2;
$mail->Username = 'test@test.net'; // GMAIL username
$mail->Password = 'test@123'; // GMAIL password
$mail->From = '';
$mail->FromName = '';
$mail->Subject = "";
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
$mail->WordWrap = 250; // set word wrap
$mail->MsgHTML($body);
$mail->AddReplyTo('','');
//$mail->AddAddress($to,$_POST['contact_person']);
$mail->AddAddress('test@test.net','webmaster');
$mail->IsHTML(true); // send as HTML
if ($mail->Send())
{
echo "Your message was sent successfully";
}
else
{
echo "There is a problem in sending your Email";
}
}