从这样的另一个线程发送电子邮件是否正常? [英] Is it fine to send email from another thread like this?

查看:364
本文介绍了从这样的另一个线程发送电子邮件是否正常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个网站上,有时候发送电子邮件需要几秒钟,所以我需要从另一个主题发送电子邮件,不要等到邮件发送。

In a website, Some times sending an email take few seconds, so I need to send email from another thread, to don't wait until the email sent.

我发现这个回覆 stackoverflow,做得很好这样一来,我会每个请求发送一个电子邮件?

I found this answer on stackoverflow, Is it fine to do it this way, incase I will send just one email per request?

还有另一种标准的方法来实现?

Or there is another standard way to do this?

推荐答案

如果可能,您应该设置一个本地SMTP服务器,该服务器只侦听环回地址(127.0.0.1),因为这正是邮件队列所用的。您可以将SMTP服务器配置为通过实际的出站邮件服务器进行中继,这样您就不会遇到SPF将邮件视为垃圾邮件的问题。

If possible, you should set up a local SMTP server that only listens on the loopback address (127.0.0.1) as this is exactly what mail queues are for. You can configure your SMTP server to relay through your real outbound mail server so that you don't run into problems with SPF treating your mail as spam.

这样您的应用程序可以快速排队出站邮件,并以快乐的方式,您可以肯定的是,即使在重负载,网络问题甚至崩溃的情况下,该消息最终都将被发送。

This way your application can quickly queue the outbound mail and be on it's merry way and you can be reasonably sure that the message will eventually be delivered even in the event of heavy load, network issues, or even a crash.

这篇关于从这样的另一个线程发送电子邮件是否正常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆