phpmailer with hotmail?

人走茶凉 提交于 2019-12-13 01:54:06

问题


I'm trying to send emails from my server by a PHP script. I used to send it by a native php function mail and everything worked OK. Here's the code I used:

$to  = $sMail;<br>
$subject = $sSubject;<br>
$message = $sMessage;

$headers  = 'From: user@domain.com' . "\r\n";<br>
$headers .= 'Reply-To: user@domain.com' . "\r\n";<br>
$headers .= 'MIME-Version: 1.0' . "\r\n";<br>
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";<br>


$bRes = mail($to, $subject, $message, $headers);

I then switched to PHPMailer, and wasn't able to send mail to Hotmail accounts (all the other still worked). Hotmail server reports the error: "550 SC-001 Mail rejected by Windows Live Hotmail for policy reasons."

This is the code I used for PHPMailer:

$mail = new PHPMailer();<br>
$mail->IsHTML(true);<br>
$mail->CharSet = 'UTF-8';<br>
$mail->From     = 'user@domain.com';<br>
$mail->FromName = 'domain.com';<br>
$mail->Subject  = $sSubject;;<br>
$mail->Body     = $sMessage;<br>
$mail->AltBody  = strip_tags($sMessage;);<br>
$mail->AddAddress($sMail);<br>
$mail->Send();<br>
$mail->ClearAddresses();<br>
$mail->ClearAttachments();

As the sending works with the native function, I'm sure my server is able to send mails to hotmail. There must be a property to set when using PHPMailer, but I can't seem to find the right one. Anyone knows something abouth this?

Thank you very much!


回答1:


Try to delete line $mail->FromName = 'domain.com';



来源:https://stackoverflow.com/questions/2124665/phpmailer-with-hotmail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!