-
-
Notifications
You must be signed in to change notification settings - Fork 962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transactional Emails #39
Comments
Implementation proposal
|
TemplatingTemplates should use a templating language to allow the actual data (customer name, order contents etc) to be interpolated when generating the HTML. The specific quirks of designing emails (needs tables for layout, inline styles etc) suggest the use of a email framework. The main contenders are: I like the look of MJML. However, it does not support templating features itself (interpolating variables, for loops) so we would need an additional templating layer which generates the MJML, which is then compiled into HTML. Handlebars is an obvious choice for the templating part. |
Relates to #39. This is mainly a proof-of-concept with a single type of email (order receipt). The general design seems to work fine though. Still to do: * Revisit config to make it as simple as possible * Implement a full default set of email types * Figure out the best format for the templates and implement templating
Relates to #39. Still need to make the templates themselves for each of the defaul email types
Relates to #39. The design could use some work but the basic functionality is there
Current status: The infrastructure is all there for transactional emails now. The only thing missing is the definition of all the email types (right now there is only "order confirmation" and "email verification". The plan is to create config and templates for the other types as development of the rest of the UI / shopfront progresses. So I'll close this issue now since the foundation is complete. |
There are a number of circumstances in which an ecommerce shop might want to generate and send an email to a customer, e.g:
There are 3 aspects to transaction emails: events, email creation, and sending.
Events
An event would be some point in a process where listeners could be notified and then decide whether or not to create and send an email. Typical events would include: account created, order transitions to a certain state.
We already have hooks in those processes governed by the FiniteStateMachine, but this is not enough. For example, a cart abandonment email is not necessarily triggered by any kind of state transition, but perhaps an automated task that runs periodically.
Therefore it would make sense to have some kind of generic event bus service (#40), whereby various events are published and then the email handler can subscribe to any of these and thereby send an email at the right moment.
Email creation
This step occurs in response to an event and is concerned with generating the body of the email. It would use some kind of templating system such as Handlebars which could be passed pertinent information from the event object (e.g. the Order and Customer entities in the case of a hypothetical OrderStateTransitionEvent) and would use this data to interpolate into the template. The result would be typically a string of HTML.
Email sending (transport)
A "transport" is a method of actually sending the mail to the recipient.
SMTP is the most common way of sending an email. A business will either use their own SMTP server, or use a service such as Mandrill or SendGrid
Local - A local email server may be used such as sendmail may be used to directly send the email.
Other - For testing purposes a mock transport may be used which simply writes the email to a file on the local file system.
Nodemailer supports all of the above transport out of the box, and new transports can be written.
The text was updated successfully, but these errors were encountered: