1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| const nodemailer = require('nodemailer')
async function sendEmail({to, subject, html}) { const user = 'admin@vincef0ng.cn', pass = 'xxxxxxxxxxxxxxxxxx' let transporter = nodemailer.createTransport({ host: 'smtp.qq.com', port: 465, secure: true, auth: { user, pass } }) const info = await transporter.sendMail({ from: `"游趣街" <${user}>`, to, subject, html }) if (info.messageId) { return {code: 1, msg: '邮件发送成功'} } else { return {code: 0, msg: '邮件发送失败', details: info} } }
module.exports = { sendContributeEmail: (info) => { const { title, question, answer, authour, create_date } = info const to = 'vincefong1018@gmail.com' const subject = '海龟汤投稿' const html = `<div style="border-radius:10px 10px 10px 10px;font-size:13px;color:#555;width:666px;margin:50px auto;border:1px solid #eee;max-width:100%;background:#fff repeating-linear-gradient(-45deg,#fff,#fff 1.125rem,transparent 1.125rem,transparent 2.25rem);box-shadow:0 1px 5px rgba(0,0,0,.15)"><div style="width:100%;background:#49bdad;border-radius:10px 10px 0 0;background-image:-moz-linear-gradient(0deg,#43c6b8,#ffd1f4);background-image:-webkit-linear-gradient(0deg,#43c6b8,#ffd1f4);height:66px"><p style="font-size:20px;word-break:break-all;padding:20px 32px;margin:0;background-color:hsla(0,0%,100%,.4);border-radius:10px 10px 0 0">海龟汤投稿</p></div><div style="margin:40px auto;width:90%;font-size:16px"><p>标题</p><div style="background:#fafafa repeating-linear-gradient(-45deg,#fff,#fff 1.125rem,transparent 1.125rem,transparent 2.25rem);box-shadow:0 2px 5px rgba(0,0,0,.15);margin:20px 0;padding:15px;border-radius:5px;font-size:14px;color:#555">${title}</div><p>汤面</p><div style="background:#fafafa repeating-linear-gradient(-45deg,#fff,#fff 1.125rem,transparent 1.125rem,transparent 2.25rem);box-shadow:0 2px 5px rgba(0,0,0,.15);margin:20px 0;padding:15px;border-radius:5px;font-size:14px;color:#555">${question}</div><p>汤底</p><div style="background:#fafafa repeating-linear-gradient(-45deg,#fff,#fff 1.125rem,transparent 1.125rem,transparent 2.25rem);box-shadow:0 2px 5px rgba(0,0,0,.15);margin:20px 0;padding:15px;border-radius:5px;font-size:14px;color:#555">${answer}</div><p>作者</p><div style="background:#fafafa repeating-linear-gradient(-45deg,#fff,#fff 1.125rem,transparent 1.125rem,transparent 2.25rem);box-shadow:0 2px 5px rgba(0,0,0,.15);margin:20px 0;padding:15px;border-radius:5px;font-size:14px;color:#555">${authour}</div><p>时间</p><div style="background:#fafafa repeating-linear-gradient(-45deg,#fff,#fff 1.125rem,transparent 1.125rem,transparent 2.25rem);box-shadow:0 2px 5px rgba(0,0,0,.15);margin:20px 0;padding:15px;border-radius:5px;font-size:14px;color:#555">${create_date}</div></div></div>`
return sendEmail({ to, subject, html }) } }
|