I'm trying to send my stream data via email using Nodemailer but for some reason, the attachment is coming up as 0 kb
when I download it and look at its info. How can I properly send the stream & it's data as an attachment? The stream should contain a PKPass
is it a better option to send the response as an attachment? I'm using passkit-generator to generate the PKPass
const stream = examplePass.generate();
res.set({
'Content-Type': 'application/vnd.apple.pkpass',
'Content-disposition': `attachment; filename=${passName}.pkpass`,
});
stream.pipe(res);
//Send the receipt email
stream.on('finish', (attach) => {
let transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 587,
secure: false,
requireTLS: true,
auth: {
user: 'email4@gmail.com',
pass: 'password',
},
});
let mailOptions = {
from: 'email4@gmail.com',
to: 'emailTo1@gmail.com',
subject: 'You\'re on your way to ',
html: '<h1>Reciept email</h1>',
attachments: [
{
filename: 'Event.pkpass',
contentType: 'application/vnd.apple.pkpass',
content: stream,
},
],
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error.message);
}
console.log('success ' + info);
});
});