如何删除“通过"使用 PHP 发送邮件时的服务器名称? [英] How to remove "via" and server name when sending mails with PHP?

查看:15
本文介绍了如何删除“通过"使用 PHP 发送邮件时的服务器名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我用 PHP 发送邮件时,目标会得到一个这样的标题:

When I send a mail with PHP the destinatary gets a header like this one:

   noreply@justwalk.it **via** de p3nlhg147.shr.prod.phx3.secureserver.net

我想删除via"部分.大多数来自网站的自动邮件都没有via",因此当然可以将其删除.

I want to remove the "via" part. Most automated mails from websites don't have the "via" so it's certainly possible to remove it.

他们是怎么做到的?

推荐答案

是的,你可以去掉via"部分.详情如下:

Yes, you can get rid the "via" part. Here's the details:

1) SPF and DKIM

首先,您需要为您发送电子邮件的域设置 SPF 记录并启用 DKIM 也是如此.这些主要用于识别您的邮件是否为垃圾邮件.

Firstly, you would need to set an SPF record for the domain you are sending emails from and enable DKIM as well. These are primarily for identifying your messages against spam.

2) "From: anything@yourdomain.com"

其次,确保您将发件人:"标头设置为您发送邮件的域上的电子邮件地址.不要假装是别人.如果您从 abc.com 发送消息,请使用发件人:someone@abc.com",而不是其他任何内容,例如 blah@def.com、yours@gmail.com 或其他任何内容.如果您希望收件人回复您的 Gmail 电子邮件而不是域电子邮件,请使用回复:"标题.发件人:"必须始终是您发送电子邮件的域电子邮件.

Secondly, make sure you are setting the "From: " header to be an email address on the domain you are sending messages from. Don’t pretend to be someone else. Use "From: someone@abc.com" if you are sending the messages from abc.com, rather than anything else, such as blah@def.com, or yours@gmail.com, or whatever. If you want the recipient to reply to your Gmail email instead of your domain email, use the "Reply-To: " header. "From: " must always be the domain email that you are sending the email from.

3) "Return-Path: return@yourdomain.com"

第三也是最重要的一点,将Return-Path:"标头设置为与From:"标头的域相同.为此使用 mail() 函数的第 5 个参数:

Thirdly and most importantly, set the "Return-Path: " header to be the same domain as that of the "From: " header. Use the 5th parameter of the mail() function for this:

mail('recipient@example.com', 'Subject', "Message Body", $headers, '-freturn@yourdomain.com')

因此此消息的返回路径将是return@yourdomain.com"(紧跟在 -f 开关之后的电子邮件地址).$headers 参数应该包含所有必要的消息头.确保发件人:"是 something@yourdomain.com.

So the Return-Path of this message would be "return@yourdomain.com" (the email address immediately following the -f switch). The $headers parameter should contain all the necessary message headers. Make sure "From: " is something@yourdomain.com.

经过这些步骤和措施后,Gmail 现在应该完全信任您来自 yourdomain.com 的邮件.邮件的via"字段应该消失,mailed-by"字段和signed-by"字段应该正确显示为 yourdomain.com.

After these steps and measures, Gmail should now completely trust your messages from yourdomain.com. The ‘via‘ field of your messages should be gone and the ‘mailed-by‘ field as well as the ‘signed-by‘ field should be correctly showing up as yourdomain.com.

希望能帮到你!

这篇关于如何删除“通过"使用 PHP 发送邮件时的服务器名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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