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. 开发者_Go百科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!
Try to delete line $mail->FromName = 'domain.com';
精彩评论