如何使用Gmail SMTP在php mailer中设置FROM


How to set FROM in php mailer using Gmail SMTP

我试图从php mailer(gmail smtp)中设置。但在收件箱中,它显示来自 mygmailaccount@gmail.com。这是我的代码:

        $this->_mail->Username = "mygmailaccount@gmail.com";
        //Password to use for SMTP authentication
        $this->_mail->Password = 'mypassword';
        $this->_mail->From="support@mydomain.com";
        $this->_mail->FromName="Support Team";
        //Set who the message is to be sent from
        $this->_mail->setFrom('support@mydomain.com', 'Support Team',false);

但是当我在收件箱中收到电子邮件时,它显示来自:mygmailaccount@gmail.com我想从:support@mydomain.com 展示

谁能帮我找出我错过了什么。

这是一个Gmail限制,尽管这并不全是坏消息!在 Gmail 偏好设置中,您可以为帐户配置别名,也可以将其用作发件人地址发送邮件。因此,您可以设置发件人地址,但只能从该预设列表中选择一个地址,而不是任何任意地址。这个问题以前在这里被问过。