通过 ASP.NET 网页发送大量电子邮件的最佳方法

发布于 2024-10-19 00:33:30 字数 358 浏览 7 评论 0原文

我编写了一个联系人管理/通信系统,用于记录人员的详细信息并允许发送大量通信。

然而,有时在发送电子邮件时会引发以下异常:

System.Threading.ThreadAbortException: Thread was being aborted

通过 ASP 发送大量电子邮件的最佳方式是什么? NET?

我正在寻找一种将所有内容保留在 ASP.NET 中的方法,

我感觉我可能需要将电子邮件存储在数据库中并拥有一个单独的 .net 控制台应用程序/ Windows 服务将它们发送出去。然而,由于额外的开发开销和我缺乏时间,这是我要考虑的最后一个选择。

I've written a contact management/communication system that records the details of people and allows for mass communications to be sent out.

However sometimes when e-mails are being sent the following exception is raised:

System.Threading.ThreadAbortException: Thread was being aborted

What is the best way to send out mass e-mails through ASP.NET?

What I'm looking for is an approach that'll keep it all in ASP.NET

I have a feeling I may need to store the e-mails in a database and have a separate .net console application/Windows Service send them out. However because of the extra development overhead and the lack of time I have, this is the last option I want to consider.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

七月上 2024-10-26 00:33:30

没有可靠的方法可以在没有中介的情况下从 .net 进行大量电子邮件广播。

我的意思是电子邮件必须在数据库或其他持久存储中排队。然后,您需要另一个应用程序(控制台、服务等)来负责监视队列并处理广播请求。

其次,不要直接从您的代码发送它们。相反,请将电子邮件发送到您控制下的本地邮件服务器,以便重新广播给实际收件人。大量的垃圾邮件检测机制(如灰名单)意味着您将花费过多的时间发送邮件、收到灰名单拒绝、等待 15 分钟(或无论多长时间),然后再次发送以查看它会通过。

即使您正在使用真正的邮件服务器,也要排队的原因是为了避免本地邮件服务器超载。

对于那些一次性的情况,从 .net 发送邮件通常没问题,特别是当所有收件人都在您的公司内部时。然而,任何时候你必须将它们以任何可靠性发送给公众,那么你就需要“成长”,可以这么说。

There is no reliable way to do mass email broadcasting from .net without some intermediary.

What I mean by this is that the emails must be queued in your database or other persisted storage. Then, you need another app (console, service, whatever) that is responsible for monitoring the queue and acting on the broadcast requests.

Second, do not send them straight from your code. Instead, send the emails to a local mail server under your control for rebroadcasting to the actual recipient. The shear number of spam detection mechanisms (like grey-listing) means that you will spend an inordinate amount of time doing things sending the message, getting a grey-list denial, waiting 15 minutes (or however long), then sending again to see it go through.

The reason for queueing even if you are going through a real mail server is to keep from overloading your local mail server.

Sending mail from .net is generally fine for those one offs, especially when all of the recipients are within your company. However, anytime you have to send them to the general public with any reliability then you need to "grow up" so to speak.

最终幸福 2024-10-26 00:33:30

查看服务代理,然后从队列中提取一个单独的应用程序来触发电子邮件。

Have a look at service broker and then have a separate application pull from the queue to fire off the email.

不如归去 2024-10-26 00:33:30

不。如果 ASP.net 请求超过超时,IIS 可以将其关闭,等等。

在这种情况下,当您想要发送电子邮件时,您需要生成一个可以执行此操作的外部进程,因为它可以运行无论需要多长时间。您可以编写一个小型可执行控制台应用程序,它知道如何发送它们,并让您的网页根据需要运行它。

Don't. ASP.net requests can be terminated by IIS if they exceed the timeout, IIS shuts them down, etc.

In this case when you want to send the emails, you want to spawn an external process that can do it, because that can run for however long is required. You could write a small little executable console app that knows how to send them, and have your web page run it as needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文