Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/kbarbounakis/most-web-mailer
- Owner: kbarbounakis
- License: bsd-3-clause
- Created: 2015-09-24T06:30:11.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-08T17:11:15.000Z (almost 2 years ago)
- Last Synced: 2024-11-10T18:50:26.584Z (7 days ago)
- Topics: data, mail, mail-templates, mailer, send, web-mailer
- Language: JavaScript
- Size: 148 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
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-templateCreate a file named html.ejs (Note: EJS is the default view engine for every MOST Web Framework application):
MOST Web Framework Team
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);
});