Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/megaads-vn/node-memail
https://github.com/megaads-vn/node-memail
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/megaads-vn/node-memail
- Owner: megaads-vn
- License: mit
- Created: 2018-10-13T02:09:48.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-15T21:22:49.000Z (about 6 years ago)
- Last Synced: 2024-12-27T09:38:40.609Z (12 days ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Node Memail
### Install and Configuration
To install this module, using command:
``` npm install memail --save```
After install completely, add file config in folder ``config`` of
root app directory name `` mail.json `` with content below:
```
{
"config_send_email": [
{
"default": [
{
"to": ["[email protected]", "[email protected]"],
"subject": "Subject default",
"name":"Name default"
}
]
},
{
"groups": [
{
"developers": ["[email protected]", "[email protected]"],
"managers": ["[email protected]", "[email protected]"]
}
]
}
]
}
```
The content file is default value for module send mail. Add to this file
content the default value what you want. If you do not want using default config email params,
you can use ``options`` with params like this:
```
var options = {
"to": ["[email protected]", "[email protected]"],
"view": "newsletter.ejs", //"content": "Content",
"data": {username: 'developer1', full_name: 'Jonh Doe'},
"subject": "Test email from first node module",
"groups": "developers",
"name" : "Test Email",
}
```
``view`` and ``data`` for using templates. Just send email text, using `content ` param.
Then, add file ``.env`` at root app directory with content below:
```
MAIL_SERVICE=Gmail
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_SECURE=true
[email protected]
MAIL_PASSWORD=create_app_password_in_gmail_setting
GOOGLE_CLIENT_ID=000000000000-xxx0.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=XxxxxXXxX0xxxxxxxx0XXxX0
GOOGLE_REFRESH_TOKEN=1/XXxXxsss-xxxXXXXXxXxx0XXXxxXXx0x00xxx
GOOGLE_ACCESS_TOKEN=ya29.Xx_XX0xxxxx-xX0X0XxXXxXxXXXxX0x
```
If using google username and password to connect smtp socket not success. You
can use google oauth2 to connect smtp socket. See this youtube link: ```https://www.youtube.com/watch?v=JJ44WA_eV8E``` to known
how to create google console app and get access token.If you using email template, create folder ``templates`` and add files ``*.ejs``