Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. router.get('/email',function (req, res) {
  2.  
  3. var pdf = require('html-pdf');
  4. var fs = require('fs');
  5.  
  6. var html = '<h3>hola</h3><p>chau</p>'
  7.  
  8. var transporter = nodemailer.createTransport({
  9. host: 'smtp.gmail.com', // mail.clubhonorarios.com
  10. port: 587,
  11. auth: {
  12. user: 'ejemplo@gmail.com',
  13. pass: 'ejemplo'
  14. }
  15. });
  16.  
  17. pdf.create(html).toStream(function(err, stream){
  18. var mailOptions = {
  19. from: 'Club Honorarios <ch@clubhonorarios.com>', //grab form data from the request body object
  20. to: 'rbrunount@gmail.com',
  21. subject: 'PDF',
  22. text: 'holaaa node cuerpo!!!',
  23. attachments: [
  24. { // stream as an attachment
  25. filename: 'ejemplo.pdf',
  26. content: stream
  27. }],
  28. };
  29.  
  30. transporter.sendMail(mailOptions,function(error, info){
  31. if(error){
  32. console.log(error);
  33. res.json({yo: 'error'});
  34. }else{
  35. console.log('Message sent: ' + info.response);
  36. res.json({yo: info.response});
  37. };
  38. });
  39.  
  40. });
  41. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement