SetFrom PHPMailer not working

时光总嘲笑我的痴心妄想 提交于 2019-12-01 03:33:05

Yes, this is a Google Mail restriction. The "From" email address must match or is automatically set that way by Google SMTP.

My solution was to add

$mail->AddReplyTo($FromEmail, $FromName);

This way at least if you reply to the message it will be delivered as described

There is another way to set from address in phpmailer and it is better supported. I found that server where i used phpmailer didn't pass email to another server from the same host. But then i change the way how i set the from address and it solve the problem.

Use:

$mail->SetFrom('donotreply@mydomain.com', 'Admin');

Instead of $mail->From and $mail->FromName.

if you want to use different email address as sentFrom, then you can set your email from gmail settings:

settings > Accounts and import > Send mail as: set another email which you want to use as from:

if you are using zoho then you can follow: settings > Mail tab > Send mail as > add from address then verify that email.

Upgrade to the latest version of PHPMailler. You should also make sure that you turn on debuging in oder to view erro messages.

$mail->SMTPDebug  = 2;

You will the identify the error. Also make sure your SMTP Server credentials are correct. Like host, username and password. Mine worked correctly

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