Email Attachments without creating a file
Hi, so I want to send invoices to my clients as an email attachment. My idea was to get all the necessary data from my DB, pass the data as props to a React PDF component, and send this PDF as as an attachment to an email using nodemailer. From the nodemailer docs: https://nodemailer.com/message/attachments/ , it seems I need to specify a path to my PDF. But I dont want to create a file, store it on s3 somwhere, send an email with its path only to delete it once the email goes through. Has anyone attempted to do something like this? Any suggestions on my approach to this?
Attachments :: Nodemailer
Nodemailer is a module for Node.js to send emails
2 Replies
Based on the docs you linked, you could base64 encode it to send it
Or you can also use
ReactPDF.renderToStream
to attach it as a Buffer (See https://github.com/diegomura/react-pdf/issues/582)
Thankyou so much, this is really helpful, lifesaver.