哪里发送电子邮件去了?服务层或web层? [英] Where does sending emails go? Service layer or web layer?

查看:202
本文介绍了哪里发送电子邮件去了?服务层或web层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有好几个星期这种设计模式的问题。我在哪里可以把用于发送电子邮件的逻辑是什么?行为可通过asp.net的MVC Web界面或通过asp.net应用程序内承载一个WCF端点进行访问。

I've been having this design-pattern problem for weeks. Where do I put the logic for sending emails? Behaviors can be accessed through the asp.net mvc web interface or through a wcf endpoint hosted inside the asp.net app.

下面是应用程序的特点:

Here are the features of the app:


  1. 电子邮件通知。

  2. 模板渲染 - 这意味着我必须知道URL结构(操作,基地址等)。

目前,我存储基础URL和路径web.config文件内,具有服务层内这个电子邮件服务。

Currently, I am storing base url and paths inside the web.config file and having this email service inside the service layer.

一个特定的特征发送确认电子邮件给用户,并发送所生成的确认网址给他们。 (不知道如何从服务层这个URL)

One particular feature is sending confirmation emails to the user and sending the generated confirm url to them. (no idea how to generate this url from the service layer)

推荐答案

电子邮件应该永远永远永远从网络层服务。你永远不希望用户同时电子邮件发送等。

Emails should never ever ever ever be served from the web layer. You never want a user to wait while an email is sending.

做的最好的事情就是创建一个持久的电子邮件队列(SQL是罚款),这另外的工作访问发送电子邮件。这使您能够重新发送失败的邮件,完全您的网络请求的线程之外运行它们的能力。

The best thing to do is create a persistent email queue ( sql is fine ) which another job accesses to send the email. This gives you the ability to re-send failed emails and run them completely outside your web request thread.

这篇关于哪里发送电子邮件去了?服务层或web层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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