Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kbarbounakis/most-web-mailer

Most Web Framework Mailer Module
https://github.com/kbarbounakis/most-web-mailer

data mail mail-templates mailer send web-mailer

Last synced: 1 day ago
JSON representation

Most Web Framework Mailer Module

Awesome Lists containing this project

README

        

# @themost/mailer

[Most Web Framework](https://github.com/themost-framework/themost) Mailer simplifies mail operations by sending either static or dynamic html emails.

Install with npm

npm install @themost/mailer

Use `@themost/mailer` to send static html emails:

import {MailHelper} from '@themost/mailer';
// init mail in the current HTTP context
new MailHelper(context).transporter({
service:'gmail',
auth:{
user:"[email protected]",
pass:"password"
}
}).from('[email protected]')
.to('[email protected]')
.subject('Hello from user')
.body('

Hello World

').send({}, function(err) {
done(err);
});

You can use default mail transporter as it is defined in application configuration section settings#mail. In this case you can omit transporter initialization. e.g.

...
"settings": {
...
"mail": {
"from": "[email protected]"
"port":587,
"host":"smtp.example.com",
"auth": {
"user":"[email protected]",
"pass":"password"
}
}
...
}

Note: MOST Web Framework Mailer uses [nodemailer](https://github.com/andris9/Nodemailer) as sender engine.

MOST Web Framework Mailer gives you also the opportunity to send dynamic mail templates by using the registered view engines. So, create a folder in app/templates/mails directory

+ app
+ templates
+ mails
+ my-first-template

Create a file named html.ejs (Note: EJS is the default view engine for every MOST Web Framework application):







Hello <%=model.name%>



Finally, send dynamic mail template:

import {MailHelper} from '@themost/mailer';
// init mail in the current HTTP context
new MailHelper(context).from('[email protected]')
.to('[email protected]')
.subject('Hello from user')
.template('my-first-template').send({ name: 'George' }, (err) => {
done(err);
});