Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var options = { format: 'A4',
- "phantomPath": "./node_modules/phantomjs/bin/phantomjs", // PhantomJS binary which should get downloaded automatically
- "phantomArgs": [], // array of strings used as phantomjs args e.g. ["--ignore-ssl-errors=yes"]
- // "script": '/url', // Absolute path to a custom phantomjs script, use the file in lib/scripts as example
- // File options
- "base": 'file://' + p,
- "timeout": 30000, // Timeout that will cancel phantomjs, in milliseconds
- };
- console.log("generating pdf")
- var date = (new Date()).getTime();
- var pdfname = date +'-'+req.body.firstname+'_'+req.body.lastname +'.pdf';
- pdf.create(html, options).toFile('./uploads/applications/'+ pdfname, function(err, res) {
- if (err) return console.log(err);
- console.log(res); // Print pdf string
- });
- var transporter = nodemailer.createTransport({
- host: "smtp-mail.outlook.com", // hostname
- secureConnection: false, // TLS requires secureConnection to be false
- port: 587, // port for secure SMTP
- auth: {
- user: "demo@outlook.com",
- pass: "password"
- },
- tls: {
- ciphers:'SSLv3'
- }
- });
- //send email to manager
- var mailOptions = {
- from: 'demo@outlook.com',
- to: 'demo@outlook.com',
- subject: '** New Application from '+req.body.firstname+' '+req.body.lastname + ' **',
- text: 'You have a new application from '+req.body.firstname+' '+req.body.lastname,
- attachments: [
- { // file on disk as an attachment
- filename: pdfname,
- path: './uploads/applications/'+ pdfname // stream this file
- }
- ]
- }
- transporter.sendMail(mailOptions, function(error, info){
- if(error){
- return console.log(error);
- }
- console.log('Message sent: ' + info.response);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement