This bundle helps you connect to your favorite (swapable) transporter and render React templates as email. It is thought to work with TypeScript and enjoy type-safety.
You can use it by either providing your own custom transport, you can customise this heavily. A common example would be to use Mailgun HTTP API to send emails:
Read more here:
And if you want to have a registered, service-dependency container that creates the transport inside your bundle, then, in the
hook() phase, listen to
setTransporter() with your own custom transport solution. Same logic would apply if you want to extend the global props (props that reach any email template).
Let's create an email template:
Now let's try to send an email:
You can use https://mjml.io/ to benefit of nicely rendered emails.
Let's hook into it right before sending so we can transform our html:
Another alternative would be to use the react version of it: https://github.com/wix-incubator/mjml-react and bypass the need of a listener.
Following the same pattern as above, you can listen to emails before they get rendered via
EmailBeforeRenderEvent and inject a variable such as "applicationUrl" or a router:
And you can have a sort of "master" interface for these global props: