3

I have a 3-tier architecture system (Data, Logic, Presentation). The Presentation layer is an ASP.Net website.

I would like to send out emails from time to time. My assumption is that such logic for sending emails should be placed in the logic-layer. However, such emails need to have a link to the path of the web-layer. An example from the top of my head is when an order is generated, the email sent needs to have a link where the user can click to pay online.

Considering this page is implemented in the Presentation layer, there is no direct link between the Logic and Presentation layer. How would one go about this, and maybe any best practices regarding this seperation of layers?

Karl Cassar
  • 6,043
  • 10
  • 47
  • 84

1 Answers1

0

It should be in logic layer, there is no harm to have links in the email.

Emails often contains link, and what if the links are hosted on the same domain.

Asif Mushtaq
  • 13,010
  • 3
  • 33
  • 42
  • Yes, but in order to build the link, the actual link can change based on the location in the Presentation Layer. So, the logic-layer would need to have a link to the presentation layer. In my eyes, it doesn't look right. The other option would be to hard-code the link, but I always try to avoid hard-coded strings, as they make the code-base extremely unmaintainable. – Karl Cassar Jun 12 '12 at 12:19
  • Alternatively you can also maintain a dictionary of links and pick up based on some tagging or you can have separate templates of emails and your logic layer will only generate emails based on the template provided. – Asif Mushtaq Jun 12 '12 at 13:01
  • The link has to be dynamically built from the OrderID, etc. so it can't be based just on a template, but also based on tokens that need to be replaced like [OrderId] -> 1234 (actual order id) – Karl Cassar Jun 12 '12 at 18:03
  • Yes, that's what I am talking about. You need some mechanism where your lets say email sender will fetch requests for sending emails from some sort of queue or the email sender will be called directly from the presentation layer provided all the information required for example orderId. – Asif Mushtaq Jun 12 '12 at 18:28