const nodemailer = require("nodemailer"); const config = require('./config') const main = async (userEmail, usermessage) => { try { // let captcha = Math.floor(Math.random() * 9000) + 1000 let transporter = nodemailer.createTransport({ host: config.host, port: config.port, auth: { user: config.user, // 用户名 pass: config.pass // 密码 }, tls: { rejectUnauthorized: false } }); let info = await transporter.sendMail({ from: '"1473" ', // sender address to: `${userEmail}`, // list of receivers subject: "邮件", // Subject line html: `

${usermessage}

` }); return 'success' } catch (error) { return 'err' } } module.exports = main