phpmailer与hotmail? [英] phpmailer with hotmail?
问题描述
我正在尝试通过PHP脚本从服务器发送电子邮件.我以前是通过本地php函数邮件发送的,并且一切正常.这是我使用的代码:
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);
然后我切换到PHPMailer,但无法将邮件发送到Hotmail帐户(其他所有邮件仍然有效). Hotmail服务器报告错误:由于策略原因Windows Live Hotmail拒绝了550 SC-001邮件."
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."
这是我用于PHPMailer的代码:
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();
当发送与本机功能一起使用时,我确定我的服务器能够将邮件发送到hotmail.使用PHPMailer时必须设置一个属性,但是我似乎找不到正确的属性.有人知道这件事吗?
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?
非常感谢您!
推荐答案
尝试删除$mail->FromName = 'domain.com';
这篇关于phpmailer与hotmail?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!