feat(DialogKeywords): integrate Nodemailer for email sending functionality
Some checks failed
GBCI / build (push) Failing after 1m56s
Some checks failed
GBCI / build (push) Failing after 1m56s
This commit is contained in:
parent
320e401cad
commit
7ababd7a80
3 changed files with 39 additions and 23 deletions
16
package-lock.json
generated
16
package-lock.json
generated
|
|
@ -127,6 +127,7 @@
|
||||||
"node-html-parser": "6.1.13",
|
"node-html-parser": "6.1.13",
|
||||||
"node-nlp": "4.27.0",
|
"node-nlp": "4.27.0",
|
||||||
"node-tesseract-ocr": "2.2.1",
|
"node-tesseract-ocr": "2.2.1",
|
||||||
|
"nodemailer": "^6.10.1",
|
||||||
"nodemon": "^3.1.7",
|
"nodemon": "^3.1.7",
|
||||||
"npm": "10.8.3",
|
"npm": "10.8.3",
|
||||||
"open": "10.1.0",
|
"open": "10.1.0",
|
||||||
|
|
@ -167,6 +168,8 @@
|
||||||
"ssr-for-bots": "1.0.1-c",
|
"ssr-for-bots": "1.0.1-c",
|
||||||
"strict-password-generator": "1.1.2",
|
"strict-password-generator": "1.1.2",
|
||||||
"stripe": "^18.0.0",
|
"stripe": "^18.0.0",
|
||||||
|
"super-strong-password-generator": "2.0.2",
|
||||||
|
"super-strong-password-generator-es": "2.0.2",
|
||||||
"svg2img": "^1.0.0-beta.2",
|
"svg2img": "^1.0.0-beta.2",
|
||||||
"swagger-client": "3.29.2",
|
"swagger-client": "3.29.2",
|
||||||
"swagger-ui-dist": "5.17.14",
|
"swagger-ui-dist": "5.17.14",
|
||||||
|
|
@ -210,8 +213,6 @@
|
||||||
"prettier-standard": "16.4.1",
|
"prettier-standard": "16.4.1",
|
||||||
"semantic-release": "24.1.0",
|
"semantic-release": "24.1.0",
|
||||||
"simple-commit-message": "4.1.3",
|
"simple-commit-message": "4.1.3",
|
||||||
"super-strong-password-generator": "2.0.2",
|
|
||||||
"super-strong-password-generator-es": "2.0.2",
|
|
||||||
"travis-deploy-once": "5.0.11",
|
"travis-deploy-once": "5.0.11",
|
||||||
"tslint": "6.1.3",
|
"tslint": "6.1.3",
|
||||||
"tsx": "^4.19.1",
|
"tsx": "^4.19.1",
|
||||||
|
|
@ -30191,6 +30192,15 @@
|
||||||
"integrity": "sha512-ySkL4lBCto86OyQ0blAGzylWSECcn5I0lM3bYEhe75T8Zxt/BFUMHa8ktUguR7zwXNdS/Hms31VfSsYKN1383g==",
|
"integrity": "sha512-ySkL4lBCto86OyQ0blAGzylWSECcn5I0lM3bYEhe75T8Zxt/BFUMHa8ktUguR7zwXNdS/Hms31VfSsYKN1383g==",
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
|
"node_modules/nodemailer": {
|
||||||
|
"version": "6.10.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.10.1.tgz",
|
||||||
|
"integrity": "sha512-Z+iLaBGVaSjbIzQ4pX6XV41HrooLsQ10ZWPUehGmuantvzWoDVBnmsdUcOIDM1t+yPor5pDhVlDESgOMEGxhHA==",
|
||||||
|
"license": "MIT-0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/nodemon": {
|
"node_modules/nodemon": {
|
||||||
"version": "3.1.7",
|
"version": "3.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.7.tgz",
|
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.7.tgz",
|
||||||
|
|
@ -42052,14 +42062,12 @@
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/super-strong-password-generator/-/super-strong-password-generator-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/super-strong-password-generator/-/super-strong-password-generator-2.0.2.tgz",
|
||||||
"integrity": "sha512-EhTep3QH9YhS/w0aMUAV4CVGesAb9JPGQfW/q7VKVJNXm/F2qzCYoJ5n3NPfGXdJvw0vI6bOv1KbIQQL98288A==",
|
"integrity": "sha512-EhTep3QH9YhS/w0aMUAV4CVGesAb9JPGQfW/q7VKVJNXm/F2qzCYoJ5n3NPfGXdJvw0vI6bOv1KbIQQL98288A==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/super-strong-password-generator-es": {
|
"node_modules/super-strong-password-generator-es": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/super-strong-password-generator-es/-/super-strong-password-generator-es-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/super-strong-password-generator-es/-/super-strong-password-generator-es-2.0.2.tgz",
|
||||||
"integrity": "sha512-7S5eBNPuym8lAAw7oxJqoSFWSI/4FuX8QjEiZLCntnxs/3xFiJjSKebBxY6ySqnUbM5t3Tf1q/nr89BBfnPTXw==",
|
"integrity": "sha512-7S5eBNPuym8lAAw7oxJqoSFWSI/4FuX8QjEiZLCntnxs/3xFiJjSKebBxY6ySqnUbM5t3Tf1q/nr89BBfnPTXw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/supports-color": {
|
"node_modules/supports-color": {
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,7 @@
|
||||||
"node-html-parser": "6.1.13",
|
"node-html-parser": "6.1.13",
|
||||||
"node-nlp": "4.27.0",
|
"node-nlp": "4.27.0",
|
||||||
"node-tesseract-ocr": "2.2.1",
|
"node-tesseract-ocr": "2.2.1",
|
||||||
|
"nodemailer": "6.10.1",
|
||||||
"nodemon": "^3.1.7",
|
"nodemon": "^3.1.7",
|
||||||
"npm": "10.8.3",
|
"npm": "10.8.3",
|
||||||
"open": "10.1.0",
|
"open": "10.1.0",
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import sgMail from '@sendgrid/mail';
|
|
||||||
import { ActivityTypes } from 'botbuilder';
|
import { ActivityTypes } from 'botbuilder';
|
||||||
import { GBLog, GBMinInstance } from 'botlib';
|
import { GBLog, GBMinInstance } from 'botlib';
|
||||||
import * as df from 'date-diff';
|
import * as df from 'date-diff';
|
||||||
|
|
@ -62,6 +61,7 @@ import { GBVMService } from './GBVMService.js';
|
||||||
import { SystemKeywords } from './SystemKeywords.js';
|
import { SystemKeywords } from './SystemKeywords.js';
|
||||||
import { WebAutomationServices } from './WebAutomationServices.js';
|
import { WebAutomationServices } from './WebAutomationServices.js';
|
||||||
import { Client } from 'minio';
|
import { Client } from 'minio';
|
||||||
|
import nodemailer from 'nodemailer';
|
||||||
const { List, Buttons } = pkg;
|
const { List, Buttons } = pkg;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -574,7 +574,6 @@ export class DialogKeywords {
|
||||||
// tslint:disable-next-line:no-console
|
// tslint:disable-next-line:no-console
|
||||||
|
|
||||||
GBLogEx.info(min, `[E-mail]: to:${to},subject: ${subject},body: ${body}.`);
|
GBLogEx.info(min, `[E-mail]: to:${to},subject: ${subject},body: ${body}.`);
|
||||||
const emailToken = process.env.EMAIL_API_KEY;
|
|
||||||
|
|
||||||
// Inline word document used as e-mail body.
|
// Inline word document used as e-mail body.
|
||||||
|
|
||||||
|
|
@ -583,24 +582,32 @@ export class DialogKeywords {
|
||||||
body = result.value;
|
body = result.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emailToken) {
|
if (GBConfigService.get('GB_MODE') !== 'legacy') {
|
||||||
return new Promise<any>((resolve, reject) => {
|
|
||||||
sgMail.setApiKey(emailToken);
|
const transporter = nodemailer.createTransport({
|
||||||
const msg = {
|
host: process.env.EMAIL_SERVER || 'localhost',
|
||||||
to: to,
|
port: parseInt(process.env.EMAIL_PORT || '587', 10),
|
||||||
from: process.env.EMAIL_FROM,
|
secure: false,
|
||||||
subject: subject,
|
auth: {
|
||||||
text: body,
|
user: process.env.EMAIL_USER ,
|
||||||
html: body
|
pass: process.env.EMAIL_PASS ,
|
||||||
};
|
},
|
||||||
sgMail.send(msg, false, (err, res) => {
|
tls: {
|
||||||
if (err) {
|
rejectUnauthorized: (process.env.EMAIL_REJECT_UNAUTHORIZED === 'true'),
|
||||||
reject(err);
|
},
|
||||||
} else {
|
|
||||||
resolve(res);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const mailOptions = {
|
||||||
|
from: process.env.EMAIL_FROM,
|
||||||
|
to: to,
|
||||||
|
subject: subject,
|
||||||
|
text: body,
|
||||||
|
html: body,
|
||||||
|
};
|
||||||
|
|
||||||
|
await transporter.sendMail(mailOptions);
|
||||||
|
GBLogEx.info(min, `E-mail ${to} (${subject}) sent via NodeMailer.`);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
let { client } = await GBDeployer.internalGetDriveClient(min);
|
let { client } = await GBDeployer.internalGetDriveClient(min);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue