Advertisement
Guest User

Untitled

a guest
Sep 12th, 2017
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. const nodemailer = require('nodemailer');
  2.  
  3. const mailConfig = {
  4. secure: true,
  5. host: 'smtp.126.com',
  6. port: 465,
  7. auth: {
  8. user: 'xxxxx@126.com', // your account and password
  9. pass: 'xxxxx'
  10. }
  11. };
  12. const transporter = nodemailer.createTransport(mailConfig);
  13.  
  14. function send(args) {
  15. const mailOptions = {
  16. from: mailConfig.auth.user,
  17. to: args.to,
  18. subject: args.subject || 'Hello ✔',
  19. html: args.html || '<b>Hello world ?</b>',
  20. };
  21.  
  22. transporter.sendMail(mailOptions, (error, info) => {
  23. if (error) {
  24. return log('send fail', error);
  25. }
  26. console.log('Message %s sent: %s', info.messageId, info.response);
  27. });
  28. }
  29.  
  30. send({
  31. to: 'xxx', // another email
  32. subject: 'test',
  33. html: '<div>test</div>'
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement