使用 gmail smtp 服务器时如何更改发件人地址 [英] How to change from-address when using gmail smtp server

查看:113
本文介绍了使用 gmail smtp 服务器时如何更改发件人地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 Gmail 从 AB 发送一封带有 HEADERCONTENT 的电子邮件.

I want to send an email from A to B,with HEADER and CONTENT through gmail.

如何通过 PHP 做到这一点?

How to do that by PHP?

我已经指定了发件人(来自@example.com),但是当我收到电子邮件时,它仍然来自我的 gmail 帐户(abc@gmail.com).

I've specified the FROM(from@example.com),but when I receive the email,it's still from my gmail account(abc@gmail.com).

$mail->From = "from@example.com";
$mail->FromName = "Mailer";
$mail->AddAddress("abc12@163.com", "Josh Adams");// name is optional
$mail->AddReplyTo("abc12@qq.com", "Information");

如何更改FROM 部分?

推荐答案

简短的回答 - 你不能.

The short answer - you can't.

Google 将您通过其 SMTP 服务发送的邮件中的 From 和 Reply-To 标头重写为与您的 Gmail 帐户相关的值.

Google rewrites the From and Reply-To headers in messages you send via it's SMTP service to values which relate to your gmail account.

gmail 的 SMTP 功能并非旨在成为开放或中继服务.如果它允许 From 标头的任何值,就会显着削弱 Google 在垃圾邮件服务方面的地位,因为将无法验证发件人的凭据.

The SMTP feature of gmail isn't intended to be an open or relay service. If it allowed any values for the From header, it would significantly dilute Google's standing with spam services, as there would be no way to verify the credentials of the sender.

您需要考虑替代方案.完成后,您打算如何托管您的脚本/应用程序/网站:几乎所有托管解决方案(共享/vps/专用服务器)都将预先配置电子邮件传输解决方案:*nix 或 IIS 上的 sendmail 或 postfix在 Windows 上.

You need to consider alternatives. How are you planning to host your script/application/website when it's finished: virtually every hosting solutions (shared/vps/dedicated server) will come pre-configured with an email transfer solution: be it sendmail or postfix on *nix, or IIS on Windows.

如果您打算使用 gmail,那么您可以:

If you are intent on using gmail then you could:

  • 设置专用的myapp@gmail.com"帐户
  • 如果您拥有应该从中发送邮件的域,请使用域的免费 G​​mail,并且设置一个myapp@mydomain.com"帐户.
  • Setup a dedicated "myapp@gmail.com" account
  • If you own the domain you are supposedly sending from, use the free gmail for domains, and setup a "myapp@mydomain.com" account.

====

有人建议 GMail 允许通过不同地址发送.据我所知,这是通过 GMail wep 应用发送,并利用您现有的外部 SMTP 服务器,这与原始问题无关.

It was suggested that GMail does allow sending via different addresses. As far as I can tell, this is for sending via the GMail wep app, and utilises your existing external SMTP server, which is not relevant to the original question.

====

看到这仍然获得了少量的选票.快速更新.

Seeing as this is still getting a trickle of votes. A quick update.

Google 已撤消了针对域的免费 G​​Mail.周围还有很多其他免费服务.其中一个值得注意的是 Mandrill - 一种用于交易电子邮件(例如电子商务)的一对一电子邮件服务订单等).它由 MailChimp 运营,他几乎了解有关批量发送电子邮件的所有知识.他们还为您提供每月 12k 的免费服务,这相当不错.

Google have withdrawn their free GMail for domains. There are plenty of other free services around. One of note is Mandrill - a one-to-one email service intended for transactional emails (e.g. ecommerce orders etc.). It's ran by MailChimp, who pretty much know all there is to know about sending email at volume. They also give you 12k/month free, which is rather nice.

这篇关于使用 gmail smtp 服务器时如何更改发件人地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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