Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const nodemailer = require('nodemailer');
- const mailConfig = {
- secure: true,
- host: 'smtp.126.com',
- port: 465,
- auth: {
- user: 'xxxxx@126.com', // your account and password
- pass: 'xxxxx'
- }
- };
- const transporter = nodemailer.createTransport(mailConfig);
- function send(args) {
- const mailOptions = {
- from: mailConfig.auth.user,
- to: args.to,
- subject: args.subject || 'Hello ✔',
- html: args.html || '<b>Hello world ?</b>',
- };
- transporter.sendMail(mailOptions, (error, info) => {
- if (error) {
- return log('send fail', error);
- }
- console.log('Message %s sent: %s', info.messageId, info.response);
- });
- }
- send({
- to: 'xxx', // another email
- subject: 'test',
- html: '<div>test</div>'
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement