Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- router.get('/email',function (req, res) {
- var pdf = require('html-pdf');
- var fs = require('fs');
- var html = '<h3>hola</h3><p>chau</p>'
- var transporter = nodemailer.createTransport({
- host: 'smtp.gmail.com', // mail.clubhonorarios.com
- port: 587,
- auth: {
- user: 'ejemplo@gmail.com',
- pass: 'ejemplo'
- }
- });
- pdf.create(html).toStream(function(err, stream){
- var mailOptions = {
- from: 'Club Honorarios <ch@clubhonorarios.com>', //grab form data from the request body object
- to: 'rbrunount@gmail.com',
- subject: 'PDF',
- text: 'holaaa node cuerpo!!!',
- attachments: [
- { // stream as an attachment
- filename: 'ejemplo.pdf',
- content: stream
- }],
- };
- transporter.sendMail(mailOptions,function(error, info){
- if(error){
- console.log(error);
- res.json({yo: 'error'});
- }else{
- console.log('Message sent: ' + info.response);
- res.json({yo: info.response});
- };
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement