When developing an application that sends out notification email messages, what are the best practices for
在开发发送通知电子邮件消息的应用程序时,有哪些最佳实践
- not getting flagged as a spammer by your hosting company. (Cover any of:)
- best technique for not flooding a mail server
- best mail server products, if you were to set up your own
- sending messages as if from a specific user but still clearly from your application (to ensure complaints, etc come back to you) without breaking good email etiquette
- any other lessons learned
不淹没邮件服务器的最佳技术
最好的邮件服务器产品,如果你要自己设置
发送消息,好像来自特定用户,但仍然清楚地从您的应用程序(以确保投诉等回复给您),而不会破坏良好的电子邮件礼仪
任何其他经验教训
- not getting flagged as spam by the receiver's client? (Cover any of:)
- configuring and using sender-id, domain-keys, SPF, reverse-dns, etc to make sure your emails are properly identified
- best SMTP header techniques to avoid getting flagged as spam when sending emails for users (for example, using Sender and From headers together)
- any other lessons learned
配置和使用sender-id,domain-keys,SPF,reverse-dns等,以确保正确识别您的电子邮件
最好的SMTP标头技术,以避免在为用户发送电子邮件时被标记为垃圾邮件(例如,一起使用Sender和From标头)
任何其他经验教训
不会被您的托管公司标记为垃圾邮件发送者。 (覆盖任何:)最好的技术,不要淹没邮件服务器最好的邮件服务器产品,如果你要设置自己的发送邮件,就像从特定用户,但仍然清楚地从您的应用程序(以确保投诉等回来你没有破坏良好的电子邮件礼仪任何其他经验教训
不会被接收方的客户端标记为垃圾邮件? (涵盖任何:)配置和使用sender-id,domain-keys,SPF,reverse-dns等,以确保您的电子邮件被正确识别为最佳SMTP标头技术,以避免在为用户发送电子邮件时被标记为垃圾邮件(例如,使用Sender和From标题一起)学到的任何其他经验教训
An additional requirement: this application would be sending a single message to a single recipient based upon an event. So, techniques for sending the same messages to multiple recipients will not apply.
附加要求:此应用程序将根据事件向单个收件人发送单个邮件。因此,向多个收件人发送相同邮件的技术将不适用。
3 个解决方案
#1
5
best technique for not flooding a mail server
不淹没邮件服务器的最佳技术
not a lot you can do about this beyond checking with your mail server admin (if it's a shared hosting account / not in your control). but if the requirement is one email to a single recipient per event, that shouldn't be too much of an issue. the things that tend to clog mail systems are emails with hundreds (or more) of recipients.
除了检查您的邮件服务器管理员(如果它是共享主机帐户/不在您的控制中)之外,您可以做很多事情。但如果要求是每个事件一个电子邮件发送给一个收件人,那不应该是一个问题。容易阻塞邮件系统的东西是包含数百(或更多)收件人的电子邮件。
if you have events firing off all the time, perhaps consider consolidating them and having an email sent that summarizes them periodically.
如果您有事件一直开火,也许可以考虑合并它们并发送一封定期汇总的电子邮件。
sending messages as if from a specific user but still clearly from your application (to ensure complaints, etc come back to you) without breaking good email etiquette
发送消息,好像来自特定用户,但仍然清楚地从您的应用程序(以确保投诉等回复给您),而不会破坏良好的电子邮件礼仪
you can accomplish this by using the "Reply-To" header, which will then have clients use that address instead of the From address when an email message is being composed.
您可以使用“Reply-To”标头完成此操作,然后在编写电子邮件消息时,客户端将使用该地址而不是“发件人”地址。
you should also set the "Return-Path" header of any email, as email without this will often get filtered off.
你还应该设置任何电子邮件的“Return-Path”标题,因为没有这个电子邮件的电子邮件通常会被过滤掉。
ex.
From: me@me.com
Return-Path: me@me.com
Reply-To: auto@myapp.com
configuring and using sender-id, domain-keys, SPF, reverse-dns, etc to make sure your emails are properly identified
配置和使用sender-id,domain-keys,SPF,reverse-dns等,以确保正确识别您的电子邮件
this is all highly dependent on how much ownership you have of your mail and DNS servers. spf/sender-id etc... are all DNS issues, so you would need to have access to DNS.
这完全取决于您对邮件和DNS服务器的拥有权。 spf / sender-id等...都是DNS问题,因此您需要访问DNS。
in your example this could present quite the problem. as you are setting mail to be from a specific user, that user would have to have SPF (for example) set in their DNS to allow your mail server as a valid sender. you can imagine how messy (if not outright impossible) this would get with a number of users with various domain names.
在你的例子中,这可能会出现相当大的问题。当您将邮件设置为来自特定用户时,该用户必须在其DNS中设置SPF(例如)以允许您的邮件服务器作为有效发件人。你可以想象这对于拥有各种域名的用户来说会有多么混乱(如果不是完全不可能的话)。
as for reverse DNS and the like, it really depends. most client ISP's, etc... will just check to see that reverse DNS is set. (ie, 1.2.3.4 resolves to host.here.domain.com, even if host.here.domain.com doesn't resolve back to 1.2.3.4). this is due to the amount of shared hosting out there (where mail servers will often report themselves as the client's domain name, and not the real mail server).
至于反向DNS等,它真的取决于。大多数客户ISP等等...只会检查是否设置了反向DNS。 (即1.2.3.4解析为host.here.domain.com,即使host.here.domain.com没有解析回1.2.3.4)。这是由于共享托管的数量(邮件服务器通常将自己报告为客户端的域名,而不是真实的邮件服务器)。
there are a few stringent networks that require matching reverse DNS, but this requires that you have control over the mail server if it doesn't match in the first place.
有一些严格的网络需要匹配反向DNS,但这要求您可以控制邮件服务器,如果它首先不匹配。
if you can be a bit more specific i may be able to provide a bit more advice, but generally, for people who need to send application mail, and don't have a pile of control over their environment, i'd suggest the following:
如果您可以更具体一点,我可以提供更多建议,但一般来说,对于需要发送应用程序邮件,并且没有对其环境进行大量控制的人,我建议以下:
- make sure to set a "Return-Path"
- it's nice to add your app and abuse info as well in headers ie: "X-Mailer" and "X-Abuse-To" (these are custom headers, for informational purposes only really)
- make sure reverse DNS is set for the IP address of your outgoing mail server
确保设置“返回路径”
很高兴在标题中添加您的应用和滥用信息,即:“X-Mailer”和“X-Abuse-To”(这些是自定义标题,仅供参考之用)
确保为外发邮件服务器的IP地址设置反向DNS
#2
0
first a quick correction to the previous
首先快速修正前一个
return-path: is a header added by recieving system based on the envelope-sender of the incomming message
return-path:是基于incomming消息的包络发送者通过接收系统添加的头
for spf to work the return-path/envelope-sender needs to be yourapp@yourdomain.com
要使spf工作,返回路径/信封发送者需要是yourapp@yourdomain.com
and ensure the spf record for yourdomain.com {or if per-user spf} for yourapp@yourdomain.com allows mails to originate on the server that hosts the app/sends the email
并确保yourdopp @yourdomain.com的yourdomain.com {或if-user spf}的spf记录允许邮件来自托管应用程序的服务器/发送电子邮件
this envelope-sender is the address that will recieve all bounces/errors
此信封发件人是接收所有退回/错误的地址
now sender-id is different entirely it checks the return-path/envelope-sender and the from: address {stored inside the message} if sending from: hisname yourapp@yourdomain.com reply-to: hisname hisaddres@hisdomain.com
现在sender-id完全不同它检查返回路径/信封发送者和来自:地址{存储在消息内}如果发送来自:hisname yourapp@yourdomain.com回复:hisname hisaddres@hisdomain.com
this will be a non-issue if sending from: hisname hisaddres@hisdomain.com
如果发送来自:hisname hisaddres@hisdomain.com,这将是一个非问题
it will be and you must add a Resent-From: hisname yourapp@yourdomain.com as this specifies to ignore the from: for sender-id checks use this instead as it has been sent by you on his behalf
它将是你必须添加一个Resent-From:hisname yourapp@yourdomain.com,因为它指定忽略from:for sender-id支票使用它,因为它是你代表他发送的
#3
0
now for the other bits that are worthwhile
现在为其他有价值的比特
ip's mentioned are your mailservers
ip提到的是你的邮件服务器
a have your ip's ptr point to a name that also resolves to the same ip FQDNS
你的ip的ptr指向一个名称,该名称也解析为同一个ip FQDNS
b have your server helo/ehlo with whatever.domain.com where domain.com is the same as the domain of the name in step A {not the same name for resons below}
b将您的服务器helo / ehlo与whatever.domain.com一起使用,其中domain.com与步骤A中的名称域相同{不同于下面的resons的名称}
c have that helo/ehlo servername also resolve to the ip of your server
c有helo / ehlo服务器名也解析为你的服务器的IP
d add the following spf record to that helo/ehlo name "v=spf1 a -all" {meaning allow helo/ehlo with this name from ip's this name points to only}
d将以下spf记录添加到helo / ehlo名称“v = spf1 a -all”{意味着允许helo / ehlo使用此名称来自ip,此名称仅指向}
e add the following sender-id lines to the helo/ehlo name {purely for completeness "spf2.0/mfrom,pra -all" {ie there are no users@this-domain}
e将以下sender-id行添加到helo / ehlo名称{纯粹为了完整性“spf2.0 / mfrom,pra -all”{即没有用户@ this-domain}
f add the following spf to the FQDNS-name and any other hostnames for your server "v=spf1 -all" {ie no machines will ever helo/ehlo as this name and no users@this-domain}
f将以下spf添加到FQDNS名称和服务器的任何其他主机名“v = spf1 -all”{即没有机器将作为此名称helo / ehlo而没有用户@ this-domain}
{as the fqdns name can be determined by bots/infections its better to never allow this name to be used in helo/ehlo greetings directly it is enough that it be from the same domain as the helo/ehlo identity to prove the validity of both}
{因为fqdns名称可以由机器人/感染确定,最好不要直接在helo / ehlo问候语中使用此名称,它足以与helo / ehlo身份来自同一域,以证明两者的有效性}
#1
5
best technique for not flooding a mail server
不淹没邮件服务器的最佳技术
not a lot you can do about this beyond checking with your mail server admin (if it's a shared hosting account / not in your control). but if the requirement is one email to a single recipient per event, that shouldn't be too much of an issue. the things that tend to clog mail systems are emails with hundreds (or more) of recipients.
除了检查您的邮件服务器管理员(如果它是共享主机帐户/不在您的控制中)之外,您可以做很多事情。但如果要求是每个事件一个电子邮件发送给一个收件人,那不应该是一个问题。容易阻塞邮件系统的东西是包含数百(或更多)收件人的电子邮件。
if you have events firing off all the time, perhaps consider consolidating them and having an email sent that summarizes them periodically.
如果您有事件一直开火,也许可以考虑合并它们并发送一封定期汇总的电子邮件。
sending messages as if from a specific user but still clearly from your application (to ensure complaints, etc come back to you) without breaking good email etiquette
发送消息,好像来自特定用户,但仍然清楚地从您的应用程序(以确保投诉等回复给您),而不会破坏良好的电子邮件礼仪
you can accomplish this by using the "Reply-To" header, which will then have clients use that address instead of the From address when an email message is being composed.
您可以使用“Reply-To”标头完成此操作,然后在编写电子邮件消息时,客户端将使用该地址而不是“发件人”地址。
you should also set the "Return-Path" header of any email, as email without this will often get filtered off.
你还应该设置任何电子邮件的“Return-Path”标题,因为没有这个电子邮件的电子邮件通常会被过滤掉。
ex.
From: me@me.com
Return-Path: me@me.com
Reply-To: auto@myapp.com
configuring and using sender-id, domain-keys, SPF, reverse-dns, etc to make sure your emails are properly identified
配置和使用sender-id,domain-keys,SPF,reverse-dns等,以确保正确识别您的电子邮件
this is all highly dependent on how much ownership you have of your mail and DNS servers. spf/sender-id etc... are all DNS issues, so you would need to have access to DNS.
这完全取决于您对邮件和DNS服务器的拥有权。 spf / sender-id等...都是DNS问题,因此您需要访问DNS。
in your example this could present quite the problem. as you are setting mail to be from a specific user, that user would have to have SPF (for example) set in their DNS to allow your mail server as a valid sender. you can imagine how messy (if not outright impossible) this would get with a number of users with various domain names.
在你的例子中,这可能会出现相当大的问题。当您将邮件设置为来自特定用户时,该用户必须在其DNS中设置SPF(例如)以允许您的邮件服务器作为有效发件人。你可以想象这对于拥有各种域名的用户来说会有多么混乱(如果不是完全不可能的话)。
as for reverse DNS and the like, it really depends. most client ISP's, etc... will just check to see that reverse DNS is set. (ie, 1.2.3.4 resolves to host.here.domain.com, even if host.here.domain.com doesn't resolve back to 1.2.3.4). this is due to the amount of shared hosting out there (where mail servers will often report themselves as the client's domain name, and not the real mail server).
至于反向DNS等,它真的取决于。大多数客户ISP等等...只会检查是否设置了反向DNS。 (即1.2.3.4解析为host.here.domain.com,即使host.here.domain.com没有解析回1.2.3.4)。这是由于共享托管的数量(邮件服务器通常将自己报告为客户端的域名,而不是真实的邮件服务器)。
there are a few stringent networks that require matching reverse DNS, but this requires that you have control over the mail server if it doesn't match in the first place.
有一些严格的网络需要匹配反向DNS,但这要求您可以控制邮件服务器,如果它首先不匹配。
if you can be a bit more specific i may be able to provide a bit more advice, but generally, for people who need to send application mail, and don't have a pile of control over their environment, i'd suggest the following:
如果您可以更具体一点,我可以提供更多建议,但一般来说,对于需要发送应用程序邮件,并且没有对其环境进行大量控制的人,我建议以下:
- make sure to set a "Return-Path"
- it's nice to add your app and abuse info as well in headers ie: "X-Mailer" and "X-Abuse-To" (these are custom headers, for informational purposes only really)
- make sure reverse DNS is set for the IP address of your outgoing mail server
确保设置“返回路径”
很高兴在标题中添加您的应用和滥用信息,即:“X-Mailer”和“X-Abuse-To”(这些是自定义标题,仅供参考之用)
确保为外发邮件服务器的IP地址设置反向DNS
#2
0
first a quick correction to the previous
首先快速修正前一个
return-path: is a header added by recieving system based on the envelope-sender of the incomming message
return-path:是基于incomming消息的包络发送者通过接收系统添加的头
for spf to work the return-path/envelope-sender needs to be yourapp@yourdomain.com
要使spf工作,返回路径/信封发送者需要是yourapp@yourdomain.com
and ensure the spf record for yourdomain.com {or if per-user spf} for yourapp@yourdomain.com allows mails to originate on the server that hosts the app/sends the email
并确保yourdopp @yourdomain.com的yourdomain.com {或if-user spf}的spf记录允许邮件来自托管应用程序的服务器/发送电子邮件
this envelope-sender is the address that will recieve all bounces/errors
此信封发件人是接收所有退回/错误的地址
now sender-id is different entirely it checks the return-path/envelope-sender and the from: address {stored inside the message} if sending from: hisname yourapp@yourdomain.com reply-to: hisname hisaddres@hisdomain.com
现在sender-id完全不同它检查返回路径/信封发送者和来自:地址{存储在消息内}如果发送来自:hisname yourapp@yourdomain.com回复:hisname hisaddres@hisdomain.com
this will be a non-issue if sending from: hisname hisaddres@hisdomain.com
如果发送来自:hisname hisaddres@hisdomain.com,这将是一个非问题
it will be and you must add a Resent-From: hisname yourapp@yourdomain.com as this specifies to ignore the from: for sender-id checks use this instead as it has been sent by you on his behalf
它将是你必须添加一个Resent-From:hisname yourapp@yourdomain.com,因为它指定忽略from:for sender-id支票使用它,因为它是你代表他发送的
#3
0
now for the other bits that are worthwhile
现在为其他有价值的比特
ip's mentioned are your mailservers
ip提到的是你的邮件服务器
a have your ip's ptr point to a name that also resolves to the same ip FQDNS
你的ip的ptr指向一个名称,该名称也解析为同一个ip FQDNS
b have your server helo/ehlo with whatever.domain.com where domain.com is the same as the domain of the name in step A {not the same name for resons below}
b将您的服务器helo / ehlo与whatever.domain.com一起使用,其中domain.com与步骤A中的名称域相同{不同于下面的resons的名称}
c have that helo/ehlo servername also resolve to the ip of your server
c有helo / ehlo服务器名也解析为你的服务器的IP
d add the following spf record to that helo/ehlo name "v=spf1 a -all" {meaning allow helo/ehlo with this name from ip's this name points to only}
d将以下spf记录添加到helo / ehlo名称“v = spf1 a -all”{意味着允许helo / ehlo使用此名称来自ip,此名称仅指向}
e add the following sender-id lines to the helo/ehlo name {purely for completeness "spf2.0/mfrom,pra -all" {ie there are no users@this-domain}
e将以下sender-id行添加到helo / ehlo名称{纯粹为了完整性“spf2.0 / mfrom,pra -all”{即没有用户@ this-domain}
f add the following spf to the FQDNS-name and any other hostnames for your server "v=spf1 -all" {ie no machines will ever helo/ehlo as this name and no users@this-domain}
f将以下spf添加到FQDNS名称和服务器的任何其他主机名“v = spf1 -all”{即没有机器将作为此名称helo / ehlo而没有用户@ this-domain}
{as the fqdns name can be determined by bots/infections its better to never allow this name to be used in helo/ehlo greetings directly it is enough that it be from the same domain as the helo/ehlo identity to prove the validity of both}
{因为fqdns名称可以由机器人/感染确定,最好不要直接在helo / ehlo问候语中使用此名称,它足以与helo / ehlo身份来自同一域,以证明两者的有效性}