svelte-mail
Renders Svelte components for emails. Inlines styles and renders additional plain text version.
Installation
Run npm i --save svelte-mail
.
Usage
Simply pass a Svelte component and some options:
./components/Mail.svelte
Hello, {user}
./sendMail.js
;; { const html text = await ; /* `html` contains the rendered html string: "<strong style="color: red">Hello, World</strong>" `text` contains the rendered plain text message: "Hello, World" */ // TODO: Send mail, e.g. using nodemailer...} ;
Note: The mail component must be compiled for server side rendering.
Options
Internally, this module uses juice to inline styles and html-to-text to render plain text messages. All options passed to the renderMail function will be passed to them:
;