用于排队、查看和拦截电子邮件的电子邮件解决方案?

发布于 2024-11-03 03:26:43 字数 512 浏览 0 评论 0原文

我们有一些电子邮件问题需要解决。

  • 如果 SMTP 服务器关闭,我们希望批处理作业将它们创建的电子邮件在某个地方排队,这样我们就不必重新运行作业。什么是一个好的排队系统?如何将电子邮件从队列发送到 SMTP 服务器?
  • 默认情况下,调试时,我们不希望发送电子邮件。我们遇到过一些开发人员在单步执行代码时无意中向用户发送电子邮件的情况。我们怎样才能防止这种情况再次发生?
  • 有时,开发人员可能需要通过附加调试器并单步执行指向生产数据的代码来手动运行批处理作业。在这种情况下,我们希望能够在实际发送之前查看批处理作业发送的任何电子邮件。有没有一种简单的方法可以在所有发送的电子邮件中识别这些电子邮件,然后暂停电子邮件的发送足够长的时间来查看它?

我们所有发送电子邮件的代码都通过 SendEmail() 函数。这可以被重构以使电子邮件在某个地方排队。我们愿意研究不同的 SMTP 服务器、构建自定义解决方案或其他东西。

你能给什么建议?是否有一个解决方案可以解决这些问题或一组解决方案?谢谢。

We have a few issues with email that we're looking to solve.

  • If the SMTP server is down, we'd like our batch jobs to queue the emails they create somewhere so we don't have to rerun the jobs. What would be a good queuing system and how would you feed the emails from the queue to the SMTP server?
  • By default, when debugging, we don't want emails to be sent. We've had a few cases when a developer unknowingly sent emails out to users while stepping through code. How can we prevent this from ever happening again?
  • Occasionally, a developer may need to run a batch job manually by attaching a debugger and stepping through code which points at production data. In this case, any email that gets sent by the batch job we'd like to be able to review before it actually gets sent. Is there an easy method of identifying these emails among all the emails being sent out and then pause the sending of the email long enough to review it?

All our code that sends email goes through a SendEmail() function. This could be refactored to have the emails queue up somewhere. We'd be willing to look at different SMTP servers, building a custom solution, or something else.

What advise can you give? Is there one solution that can handle these issues or a set of solutions? Thanks.

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

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

发布评论

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

评论(2

最舍不得你 2024-11-10 03:26:43

我们通过使用 try/catch 解决了 SMTP 服务器不可用的问题 - 如果标准 SMTP 服务器不可用,我们通过写入 SMTP 拾取目录来使用 IIS 提供的 SMTP 服务,如下所示:

http://systemnetmail.com/faq/4.7.aspx

它可以满足您的需求 - 写道将电子邮件发送到队列,以便在可能时发送。

将电子邮件写入 IIS 服务器的 SMTP
服务取件目录是另一个
System.Net.Mail 的新功能。这
SMTP 拾取目录是一个特殊的
Microsoft SMTP 使用的目录
发送电子邮件的服务。任何电子邮件文件
在该目录中找到并进行处理
并通过 SMTP 传送。如果
传送过程失败,文件是
存储在队列目录中
另时间发货。如果致命的
发生错误(如DNS解析
错误),文件被移动到
死信目录。

当然,这意味着确保相关 Web 服务器上安装了 SMTP 服务。

这比我们打算走的路线简单得多,这意味着在某个地方(文件系统、数据库等)写入序列化电子邮件,然后设置一个服务来尝试按计划发送它们。自从我们实施这个以来,我们没有遇到任何问题。这不是保证,但我只是说,它对我们来说非常有效。

We solved the unavailablity of the SMTP Server issue by using a try/catch - if the standard SMTP server isn't available, we use the SMTP services provided by IIS by writing to the SMTP Pickup Directory as shown here:

http://systemnetmail.com/faq/4.7.aspx

It does what you're looking for - writes the emails to a queue that will send when possible.

Writing email to the IIS Server's SMTP
service pickup directory is another
new feature of System.Net.Mail. The
SMTP pickup directory is a special
directory used by Microsoft's SMTP
service to send email. Any email files
found in that directory are processed
and delivered over SMTP. If the
delivery process fails, the files are
stored in a queue directory for
delivery at another time. If a fatal
error occurs (such as a DNS resolution
error), the files are moved to the
Badmail directory.

This means, of course, ensuring that SMTP services are installed on the web server in question.

This was much simpler than the route we intended to go down, which would have meant writing serialized emails somewhere (file system, database, etc) and then setting up a service to try to send them on a scheduled basis. We haven't had any issues at all since we implemented this. That's not a guarantee, but I'm just saying, it worked very nicely for us.

天邊彩虹 2024-11-10 03:26:43

如果您想在运行调试版本时阻止发送电子邮件,您可以编写:

void SendEmail()
{
#if DEBUG
    // do nothing
#else
    // do normal send
#endif
}

如果您想要在可能的 SMTP 中断的情况下工作的功能,您需要将它们排队到一个文件中,并让一个单独的进程读取该文件并发送电子邮件,根据需要重试。

如果您想在发送之前查看一些电子邮件,请让批处理文件使用命令行开关启动程序。当 SendEmail 方法将电子邮件存储在文件中时,让它写入该值。发送/重试的进程不会发送任何附加该标志的消息。相反,它将这些内容放入另一个队列中进行审查。

If you want to prevent sending emails when running the debug version, you can write:

void SendEmail()
{
#if DEBUG
    // do nothing
#else
    // do normal send
#endif
}

If you want something that will work in the face of possible SMTP outages, you'll need to queue them to a file and have a separate process read that file and send the emails, retrying as required.

If you want to review some emails before sending them, have the batch file start the program with a command line switch. When the SendEmail method stores the emails in the file, have it write that value. The process that sends/retries will not send any message that has that flag attached. Rather, it puts those into another queue for review.

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