如何使用Gmail SMTP在php邮件中设置发件人

如何使用Gmail SMTP在php邮件中设置发件人,php,email,smtp,phpmailer,Php,Email,Smtp,Phpmailer,我试图在php邮件程序(gmail smtp)中设置。但在收件箱中,它显示的是mygmailaccount@gmail.com. 这是我的密码: $this->_mail->Username = "mygmailaccount@gmail.com"; //Password to use for SMTP authentication $this->_mail->Password = 'mypassword';

我试图在php邮件程序(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首选项中,您可以为您的帐户配置别名,并可以将其作为您的发件人地址发送出去。因此,您可以设置发件人地址,但只能设置为预设列表中的一个选项,而不能设置任何任意地址。这个问题以前在这里被问过。

我想这可能是Gmail的限制。“发件人”电子邮件地址必须与其来源的地址相匹配,或者由Google SMTP自动设置。的可能重复