I have code that send email with nodemailer in nodejs but I want to attach file to an email but I can\'t find way to do that I search on ne
Just look at here. Nodemailer > Message configuration > Attachments
The code snippet is below (pdfkit gets the stream):
// in async func
pdf.end();
const stream = pdf;
const attachments = [{ filename: 'fromFile.pdf', path: './output.pdf',
contentType: 'application/pdf' }, { filename: 'fromStream.pdf', content: stream, contentType: 'application/pdf' }];
await sendMail('"Sender" ', 'reciver@test.com', 'Test Send Files', 'Hello
', attachments);
Stream uses content not streamSource This bothered me before, share with everyone :)