PHPMailer .Exception:SendAsDeniedException.MapiExceptionSendAsDenied

喜欢而已 提交于 2019-11-29 14:11:06

I'd guess that the culprit is this:

$mail->FromName = trim_input($_POST['Name']);

What you're doing here is asking outlook to forge the from address by using arbitrary user input. This is generally a bad idea. The error message name suggests that this is where the problem is too: SendAsDeniedException, i.e. it doesn't like who you're sending as.

Try this instead:

$mail->From = trim_input("receivingEmailAdress@outlook.com");
$mail->FromName = trim_input($_POST['Name']);
$mail->AddAddress("receivingEmailAdress@outlook.com", "my name");
$mail->AddReplyTo(trim_input($_POST['Email']), trim_input($_POST['Name']));

This is: put your own address as the from address (so you're not forging anything), and use the submitter's address as a reply to, and also use their name alongside the from address.

This problem is covered in the PHPMailer troubleshooting guide.

This error can also mean another thing as it did for me. So make sure also if the $mail->From address is the same as the address you're using to authorize because otherwise you'll see this error:

554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied;
Failed to process message due to a permanent exception with message Cannot submit message.
Jeff Kremer

Office 365 requires the "<" and ">" characters since September 1st, 2018.

This can often be fixed by updating the settings on the device or printer by adding angle brackets ("<" and ">") around the Reply or Mail From address.

See Microsoft's support for details.

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