using these versions
"next": "12.0.7"
"nodemailer": "^6.7.2"
I am building a mailing service using NextJS, but i encountered some problems:
- gmail not rendering the images (solved by sending as attachment the images i want to render)
- In production, the mailing service can't find the images inside the public folder
- Mails sent in dev environment work perfect, but in production the images don't render
I have the following structure
pages
-api
-contact.js
public
-images
-image_name.png
in contact.js
as suggested here
...
mailData = {
from: process.env.THE_EMAIL,
to: req.body.email,
subject: `SOME_SUBJECT`,
attachments: [
{
filename: 'image_name.png',
path: 'public/images/image_name.png',
cid: 'SOME_ID_FOR_NODEMAILER',
}
]}
...
When Im working in localhost, the mailing service works perfect and the images are found, but when is in production (deployed with Vercel) it cannot find the images.
Any thoughts or alternatives? Should i host the images in a CDN and forget about it?