PHPmailer gmail'from'是gmail账户 [英] PHPmailer gmail 'from' is gmail account

查看:149
本文介绍了PHPmailer gmail'from'是gmail账户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用PHPmailer和gmail发送一封邮件。但是,当我从我的Gmail帐户发送邮件而不是没有回复。



代码我有:

  $ mail = new PHPMailer(); 

$ mail-> Mailer =smtp;
$ mail-> Host =ssl://smtp.gmail.com;
$ mail->端口= 465;
$ mail-> SMTPAuth = true;
$ mail->使用者名称=myAccount@web.com;
$ mail->密码=密码;

$ mail-> From =no-reply@web.com;
$ mail-> AddAddress($ to);
$ mail-> AddReplyTo(no-reply@web.com,no-reply);

$ mail-> Subject = $ subject;
$ mail-> Body = $ msg;
$ mail-> WordWrap = 150;
$ mail-> send();

我收到的邮件(标题):

 返回路径:< myAccount@web.com> 

哪些应该是no-reply@web.com



预先致谢

解决方案

您无法做到这一点。试想一下,发送邮件提示用您的银行帐户凭据从地址 validation@yourbank.com 回复。

要有无回复地址,您必须有权访问 @ your.domain 中的邮件服务器gmail)并在那里创建这样的账户,然后使用这个账户发送电子邮件。


I'm trying to send a mail with PHPmailer and gmail. But when I send a mail its from my gmail account instead of no-reply. How do I set no-reply as from?

Code I have:

$mail = new PHPMailer();  

$mail->Mailer = "smtp";
$mail->Host = "ssl://smtp.gmail.com";
$mail->Port = 465;
$mail->SMTPAuth = true; 
$mail->Username = "myAccount@web.com"; 
$mail->Password = "password"; 

$mail->From     = "no-reply@web.com";
$mail->AddAddress($to);  
$mail->AddReplyTo("no-reply@web.com","no-reply");

$mail->Subject  = $subject;
$mail->Body     = $msg;
$mail->WordWrap = 150; 
$mail->send();

The mail I get receives (headers):

Return-Path: <myAccount@web.com>

Which should be no-reply@web.com

Thanks in advance

解决方案

You can't do it. Just imagine sending mail prompting to reply with your bank account credentials from an address validation@yourbank.com.

To have no-reply address you must have an access to the mail server in @your.domain (not gmail) and create such account there, then send emails using this account.

这篇关于PHPmailer gmail'from'是gmail账户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆