123456789101112131415161718192021222324252627282930313233 |
- 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" <postmaster@mail.1473.cn>', // sender address
- to: `${userEmail}`, // list of receivers
- subject: "邮件", // Subject line
- html: `<h2>${usermessage}</h2>`
- });
- return 'success'
- } catch (error) {
- return 'err'
- }
- }
- module.exports = main
|