Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. const nodemailer = require('nodemailer');
  2. const transporter = nodemailer.createTransport({
  3. host: 'smtp.office365.com',
  4. port: 587,
  5. secure: false, // secure:true for port 465, secure:false for port 587
  6. auth: {
  7. user: 'gil.felot@myaccount.com',
  8. pass: 'MyPassWord'
  9. }
  10. });
  11.  
  12. // Check the connection to the service.
  13. transporter.verify(function(error, success) {
  14. if (error) {
  15. console.log(error);
  16. } else {
  17. console.log('Server is ready to take our messages');
  18. }
  19. });
  20.  
  21. const email = {
  22. from: 'gil.felot@myaccount.com', // sender address
  23. to: 'mygmailaccount@gmail.com', // list of receivers
  24. subject: 'Test Nodemailer', // Subject line
  25. // text: req.body.text, // plaintext body
  26. html: '<b>Hello world 🐴</b>', // html body
  27. attachments: [
  28. {
  29. filename: file.originalname,
  30. contents: new Buffer(file.buffer, 'base64'),
  31. encoding: 'base64'
  32. }
  33. ]
  34. };
  35.  
  36. return hook.app.service('mail').create(email)
  37. .then(function (result) {
  38. console.log('Sent email', result);
  39. }).catch(err => {
  40. console.log(err);
  41. });
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement