mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
1.0.0-preview
This commit is contained in:
1 parent
90b06d6aa7
commit
8cd84f29e8
18 files changed
+152
-401
No files matched your search
+13
-17
@@ -1,22 +1,6 @@
|
||||
const nodemailer = require('nodemailer');
|
||||
const options = require('../options');
|
||||
const { SendMailError } = require('../error');
|
||||
|
||||
let transporter = null;
|
||||
try {
|
||||
transporter = nodemailer.createTransport({
|
||||
host: options.VJ_SMTP_HOST,
|
||||
port: options.VJ_DB_PORT,
|
||||
secure: options.VJ_SMTP_SECURE,
|
||||
auth: {
|
||||
user: options.VJ_SMTP_USER,
|
||||
pass: options.VJ_SMTP_PASSWORD,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* @param {string} to
|
||||
@@ -27,9 +11,21 @@ module.exports = {
|
||||
async sendMail(to, subject, text, html) {
|
||||
let t;
|
||||
try {
|
||||
const system = require('../model/system');
|
||||
const [host, port, secure, user, pass, from] = await Promise.all([
|
||||
system.get('smtp.host'),
|
||||
system.get('smtp.port'),
|
||||
system.get('smtp.secure'),
|
||||
system.get('smtp.user'),
|
||||
system.get('smtp.pass'),
|
||||
system.get('smtp.from'),
|
||||
]);
|
||||
const transporter = nodemailer.createTransport({
|
||||
host, port, secure, auth: { user, pass },
|
||||
});
|
||||
t = await new Promise((resolve, reject) => {
|
||||
transporter.sendMail({
|
||||
from: options.VJ_SMTP_FROM,
|
||||
from,
|
||||
to,
|
||||
subject,
|
||||
text,
|
||||
|
||||
Reference in new issue
Block a user