Guest User

Untitled

a guest
Nov 24th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. const nodemailer = require('nodemailer');
  2.  
  3. module.exports = function({ props }) {
  4. return new Promise((resolve, reject) => {
  5. nodemailer.createTestAccount((err, account) => {
  6. let transporter = nodemailer.createTransport({
  7. host: this._config.host,
  8. port: this._config.port,
  9. secure: !!this._config.is_secure,
  10. auth: {
  11. user: this._config.auth.user,
  12. pass: this._config.auth.pass
  13. }
  14. });
  15.  
  16. // setup email data with unicode symbols
  17. let mailOptions = {
  18. from: `"${this._config.sender}" <${this._config.auth.user}>`,
  19. to: props.reciver,
  20. subject: props.subject,
  21. [props.html ? "html" : "text"]: props.html ? this._data : props.data
  22. };
  23.  
  24. transporter.sendMail(mailOptions, (error, info) => {
  25. if (error) {
  26. return reject(error);
  27. }
  28. resolve();
  29.  
  30. });
  31. });
  32.  
  33.  
  34. });
  35. }
Add Comment
Please, Sign In to add comment