@paralect/mail-service-client
v0.0.3
Published
Mail service by Paralect ======================== This client service by Paralect. It is using [mailgun node client](https://www.npmjs.com/package/mailgun-js) to send emails. We are inspired by [mjml](https://github.com/mjmlio/mjml) project. So, you can u
Downloads
7
Keywords
Readme
Mail service by Paralect
This client service by Paralect. It is using mailgun node client to send emails. We are inspired by mjml project. So, you can use mjml in your project and after compiling templates to simple html files use our project to inject params by handlebars and send emails. Let's dive into the docs.
MailService class
To create a MailService class you should provide several params to its constructor
const MailService = require('@paralect/mail-service-client');
const mailService = new MailService({
isSendEmail: false, // you can prevent email sending by this param
savedEmailHtmlPath: __dirname, // if you want to save your email as html in development mode
mailgun: { // configs for https://www.npmjs.com/package/mailgun-js
apiKey: 'test',
domain: 'test.info',
},
templatesDir: __dirname, // absolute path to templates directory
});
After that you are able to run send method with several params
send(templateName, templateData, data = {})
templateName - the template name which can be built by mail-service-build command (it should contain extension now, for example, report.html) templateData - template data which will be injected to the template data - additional email data (subject, email logo and etc.)
That's all folks!