lib gmail y codigo para enviar correos

This commit is contained in:
Lemuel Marquez
2021-04-27 23:38:27 -05:00
parent 666bab318c
commit c81de74054
3 changed files with 33 additions and 0 deletions
+14
View File
@@ -862,6 +862,15 @@
"ini": "1.3.7"
}
},
"gmail-send": {
"version": "1.8.10",
"resolved": "https://registry.npmjs.org/gmail-send/-/gmail-send-1.8.10.tgz",
"integrity": "sha512-QMpWwzeA64U69HzOEzI37UNc73xXkhTg8LuqsfKX9W7LjiQY3yRvViVn7ZhuJWLTV4136vsLJf2sXiZKmdykbw==",
"requires": {
"lodash": "^4.17.15",
"nodemailer": "^6.3.0"
}
},
"got": {
"version": "9.6.0",
"resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz",
@@ -1393,6 +1402,11 @@
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
},
"nodemailer": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.5.0.tgz",
"integrity": "sha512-Tm4RPrrIZbnqDKAvX+/4M+zovEReiKlEXWDzG4iwtpL9X34MJY+D5LnQPH/+eghe8DLlAVshHAJZAZWBGhkguw=="
},
"nodemon": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.7.tgz",
+1
View File
@@ -25,6 +25,7 @@
"csvtojson": "^2.0.10",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"gmail-send": "^1.8.10",
"jsonwebtoken": "^8.5.1",
"mariadb": "^2.5.3",
"moment": "^2.29.1",
+18
View File
@@ -0,0 +1,18 @@
require('../config/config');
const send = require('gmail-send')({
user: process.env.GMAIL,
pass: process.env.GMAILPASSWORD,
});
const gmail = (subject, to, text) => {
return new Promise((resolve, reject) => {
send({ subject, to, text }, (error, result, fullResult) => {
if (error) reject(error);
console.log(fullResult);
resolve(result);
});
});
};
module.exports = gmail;