来自网络应用程序/工具的邮件中继
从网络应用程序发送邮件通知的最佳方式是什么?
我有一个使用谷歌应用程序进行邮件服务的域。
我希望我的应用程序能够向用户发送邮件,并且我尝试使用 asp.net 的 SmtpClient 来执行该工作。
由于我发送的邮件超过 50 封,Google 屏蔽了我的发件人用户。
执行此任务的最佳方法是什么?我应该安装自己的邮件服务器吗?谷歌提供这样的服务吗?
谢谢, 利奥尔
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
升级到 Google Apps for Business,您将获得更高的每日配额。 :)
另外,还有一类称为电子邮件传送服务的应用程序。他们会为您处理电子邮件,因此您不必在开发过程中运行邮件服务器。我推荐SendGrid。
Upgrade to Google Apps for Business and you'll have a higher per day quota. :)
Also, there's a class of applications known as email delivery services. They take care of emailing for you, so you don't have to run a mail server as part of your development. I recommend SendGrid.
有四个选项,其中只有一个非常好(在我看来);)
不可用的选项 在您的网络服务器 IP 地址上设置 SPF 记录并直接从那里发送邮件。这是非常高的维护成本,因为大多数电子邮件提供商都有白名单,其中包含他们接受电子邮件的 IP。这已经是很多年前的事情了,但现在已经不再是了。
非常高的容量选项 使用 mailchimp 等 API 通过 API 调用发送邮件。这是一个很好的解决方案,除非 API 关闭,否则您的 Web 应用程序需要能够对此进行错误处理。而且它相当昂贵,而你可以免费获得一个普通的 SMTP 地址。如果您的邮件量非常大,也许可以使用 mailchimp 之类的东西。无论如何,如果您发送新闻通讯等,您需要一个为此构建的提供商,或者您需要调整提供商设置中的限制。否则您可能会受到速率限制。
Web 应用程序具有 SMTP 凭据选项 如果您在 Web 应用程序中导入一个库来进行 SMTP 通信,并且向该库提供您的 SMTP 凭据,请确保它可以执行错误处理,而不仅仅是将某些内容记录到错误中然后扔掉邮件。这是“释放电子邮件”的好方法。
恕我直言,最佳解决方案:本地邮件中继 使用 Postfix 或 OpenSMTPD 的本地邮件中继,您可以在其中设置您希望 Web 应用程序用来发送邮件的 SMTP 帐户的 SMTP 身份验证凭据。从 webapps 的角度来看,您所要做的就是设置正确的发件人 (MAIL FROM) 地址,然后将邮件发送到 127.0.0.1:25。邮件中继将完成剩下的工作。如果您受到速率限制,邮件中继会将邮件保留在其队列中,并定期重试。
我个人认为使用邮件中继是最好的方法。您可以使用 Postfix 来完成此操作,但对于如此小的任务来说,配置相当烦人。 Postfix 更适合较大的邮件环境(许多邮件用户的传入和传出),并且对于简单的邮件中继来说设置和调试过于复杂。我最近切换到 OpenSMTPD 并且对此非常满意。
有很多关于如何使用 这个是我迄今为止发现的最详细且易于遵循的一个。
使用 mail in a box 或类似的 FOSS 工具等解决方案可以运行您自己的邮件服务器。不过,我个人并不建议这样做,因为大型邮件提供商通常都有白名单(我指的是微软),它们只会阻止您的邮件,然后您必须维护该邮件服务器并采取措施来解锁您的 IP。许多较小的电子邮件提供商也陷入了可疑的阻止列表计划,您必须向阻止列表提供商付费才能解锁您的 IP(永远不要这样做 - 像 spamhouse会在一段时间后自动解锁您)。
There are four options, only one of which is very good (in my opinion) ;)
depricated option Set SPF records on your webservers IP address and send mails directly from there. Thats very high maintenance as most Email providers have whitelists with IPs from which they accept emails. This has been a thing many years ago, but isn't anymore.
very high volume option Use an API like mailchimp to send mails via API calls. Thats a good solution unless the API is down, then your webapp needs to be able to do error handling for that. Also its rather pricey while you can get a normal SMTP address for free. If you have a very high volume of mails, maybe go with something like mailchimp. In any case, if you send out newsletters or so, you need a provider thats build for that, or you need to adjust the limits in the providers settings. Otherwise you might get rate limited.
webapp has SMTP credentials option If you import a library in your webapp to talk SMTP, and you give this library your SMTP credentials make sure it can do error handling and will not just log something to error and then drop the mail. Thats a good way to "loose emails".
imho best solution: local mailrelay Use a local mailrelay using Postfix or OpenSMTPD, where you setup SMTP authentication credentials of the SMTP account(s) that you want your webapp to send mails with. From your webapps perspective all you have to do is set the correct sender (MAIL FROM) address and then give the mail to 127.0.0.1:25. The mailrelay will do the rest. If you get rate limited the mailrelay will keep the mails in its queue and try again periodically.
Personally I think using a Mailrelay is the the best approach. You can do this with Postfix, but the config is rather annoying for such a small task. Postfix is more suited to larger Mail environments (incoming and outgoing for many mail users) and just to complex to setup and debug for a simple mailrelay. I have recently switched to OpenSMTPD and am very happy with it.
There are many tutorials on how to setup a SMTP mailrelay for webservers with this one being the most detailed and easy to follow one I have found so far.
Running your own mailserver is possible with solutions like mail in a box or similar FOSS tools. I personally wouldn't recommend that though, as often times large mail providers have whitelists (I'm looking at you microsoft) that will just block your mails, and then you have to maintain that mailserver and do things to get your IP unblocked. Many smaller email providers also fell for dubious blocklist schemes, where you have to pay the blocklist provider to unblock your IP (NEVER do that - a good blocklist like spamhouse will unblock you automatically after a period of time).