验证电子邮件 PHP
我有一个网络应用程序,需要向客户的“发件人”员工电子邮件地址发送电子邮件。防止我的邮件被标记为垃圾邮件的最佳方法是什么?
例如,如果我拥有[电子邮件受保护],我想能够在我的应用程序中使用 PHP“从”该地址发送邮件,而无需获取“此消息可能不是由......发送的”消息。
现在我只是在 PHP 中使用 mail() 函数,以及 From、Return Path 和 X-Mailer 变量的标头。
到目前为止,我读到的有关 SPF 和 DKIM 的所有内容通常都让我感到非常困惑,所以我很感谢您的建议。谢谢。
I have a web app which needs to send emails to clients 'From' staff email addresses. What's the best way to prevent my messages from being flagged as spam?
For instance, if I own [email protected], I'd like to be able to send mail "From" that address with PHP in my App, without getting the "This message may not have been sent by...." message.
Right now I'm just using the mail() function within PHP, with Headers for the From, Return Path, and X-Mailer variables.
I'm generally pretty confused by everything I've read so far about SPF and DKIM, so I appreciate any advice. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是一个非常冗长的主题,有很多的事情到 考虑。
最重要的规则是不使用 HTML,只发送人们想要的正确邮件,并且收件人不会将自己标记为垃圾邮件。
This is a very lengthy subject with lots of things to consider.
The most important rule is to not use HTML and to send only correct mails that people want, and that the recipients do not flag as spam theirselves.
如果您拥有 Gmail 地址,则可以通过 Gmail 的 SMTP 服务发送消息,但请记住,gmail 有一个 500 封电子邮件发送限制。以下主题描述了如何将 gmail 的 SMTP 服务器与流行的 PHPMailer 结合使用。
外包这可能是使用的方法,例如:
要了解定价,请访问 http://sendgrid.com/pricing.html
http://aws.amazon.com/ses/pricing/
仅举几例,使用起来非常便宜,没有任何麻烦/设置。
If you own a gmail address you could just sent the messages via gmail's SMTP service, but keep in mind that gmail has a 500 email sent limit. Below is a topic describing how to use gmail's SMTP server with the popular PHPMailer.
Outsourcing this is probably the way to go using for example:
To read pricing visit http://sendgrid.com/pricing.html
http://aws.amazon.com/ses/pricing/
Just to name a few which are very cheap to use without any hassle/setup.
如果您不使用 mail() 函数,而是使用 SMTP 邮件程序,例如 PEAR 邮件程序包然后您可以使用 google 自己的 SMTP 服务器发送邮件。这将要求您向您希望发送的 Google 帐户提供正确的凭据。这应该可以避免您遇到的问题。
If instead of using the mail() function, you use an SMTP mailer such as the PEAR mailer package then you can send the mail using google's own SMTP servers. This will require you to provide the correct credentials to the google account you wish to send from. This should avoid the issue you are having.
您需要确保的第一件事是电子邮件“发件人:...”确实来自您的服务器,例如 [电子邮件受保护]并且它必须存在并且是脚本运行的服务器上的有效电子邮件。您应该尝试在脚本顶部设置 sendmail 用户(假设 Linux 服务器):
ini_set('sendmail_from', 'your_email@your_server.com');
然后添加一个
"Reply -To:"
标题并使用您的员工地址,收件人至少看起来会收到一封可以回复的电子邮件。如果没有它,您可能甚至不会成为垃圾邮件,您会在到达那里的途中被阻止。这个帖子展示了其中的一些内容,并注意 PHPMailer 上的评论 - 这是处理邮件的好方法,我发现它比简单的
mail();
更成功PHP 邮件表单无法正常工作
One of the first things you need to ensure is that the email "From:..." really is from your server e.g [email protected] and it must exist and be a valid email on the server where the script works. You should try setting the sendmail user at the top of your script (assumes Linux server):
ini_set('sendmail_from', 'your_email@your_server.com');
Then you add a
"Reply-To:"
header and use your staff addresses perhaps and recipients will at least seem to have got an email that can be replied to. Without that you probably won't even get as far as being spam, you will get blocked on the way there.This thread shows some of that and note the comments on PHPMailer - it is a good way to handle mailing and I have found it more successful than simple
mail();
PHP mail form isn't working