Advertisement
Guest User

Untitled

a guest
Aug 10th, 2017
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. var options = { format: 'A4',
  2. "phantomPath": "./node_modules/phantomjs/bin/phantomjs", // PhantomJS binary which should get downloaded automatically
  3. "phantomArgs": [], // array of strings used as phantomjs args e.g. ["--ignore-ssl-errors=yes"]
  4. // "script": '/url', // Absolute path to a custom phantomjs script, use the file in lib/scripts as example
  5. // File options
  6. "base": 'file://' + p,
  7. "timeout": 30000, // Timeout that will cancel phantomjs, in milliseconds
  8. };
  9.  
  10. console.log("generating pdf")
  11. var date = (new Date()).getTime();
  12. var pdfname = date +'-'+req.body.firstname+'_'+req.body.lastname +'.pdf';
  13. pdf.create(html, options).toFile('./uploads/applications/'+ pdfname, function(err, res) {
  14. if (err) return console.log(err);
  15. console.log(res); // Print pdf string
  16. });
  17.  
  18. var transporter = nodemailer.createTransport({
  19. host: "smtp-mail.outlook.com", // hostname
  20. secureConnection: false, // TLS requires secureConnection to be false
  21. port: 587, // port for secure SMTP
  22. auth: {
  23. user: "demo@outlook.com",
  24. pass: "password"
  25. },
  26. tls: {
  27. ciphers:'SSLv3'
  28. }
  29. });
  30.  
  31. //send email to manager
  32. var mailOptions = {
  33. from: 'demo@outlook.com',
  34. to: 'demo@outlook.com',
  35. subject: '** New Application from '+req.body.firstname+' '+req.body.lastname + ' **',
  36. text: 'You have a new application from '+req.body.firstname+' '+req.body.lastname,
  37. attachments: [
  38. { // file on disk as an attachment
  39. filename: pdfname,
  40. path: './uploads/applications/'+ pdfname // stream this file
  41. }
  42. ]
  43. }
  44.  
  45. transporter.sendMail(mailOptions, function(error, info){
  46. if(error){
  47. return console.log(error);
  48. }
  49. console.log('Message sent: ' + info.response);
  50. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement