0

We have a web site that requires users to signup and they then receive an activation email

Our current method of doing this is including the whole email process within the registration thread itself i.e.

Register() {
   registerUser()
   sendActivationMail()
   return View(Successpage)
}

Where sendActivationMail then contains all the necessary code to connect to our mail server and send the email etc. We know this isn't the best way to do it, rather we just did this quickly to test everything out. The problem is obvious, the user ends up waiting longer for the "thank you for signing up page" as the page is only returned after everything else has finished.

The options to this properly that we're aware of are:

  1. Start a new thread to send out the email once the database side of the registration is complete and return the original thread immediately.
  2. Persist the email to the database and have a thread that runs contiounously and checks the database for new emails to send every x minutes
  3. Use a third party email service such as Amazon Simple Email Service.

Are there any other methods to use? Do any of the above stand out as the best?

Thanks in advance for any help.

4

2 回答 2

2

我们使用数据库对消息进行排队,我有一个服务应用程序,它连续运行并检查队列并将它们发送出去。我们有一堆发送电子邮件的 Web 应用程序,所以它们都放入队列中。这对我们有用。我确信它有利有弊,但就像我说的,它对我们有用。

于 2012-04-30T15:51:20.067 回答
1

这取决于您的需求。

方法 2 的优点是,如果发送失败,您可以重试/决定要做什么。

另一种类似于数据库的方法是一些队列基础设施,如 MSMQ 或其他。

于 2012-04-30T15:50:51.057 回答