I'm trying to attach images to an email to display them later. I'm using NextJS and I'm doing that using the serverless functions.
const letter: any = {
from: 'ME',
replyTo: 'ME',
to: `<${email}>`,
subject: "subject",
text,
html,
attachments: [
{
filename: "mastercard.png",
path: `${__dirname}/mastercard.png`,
cid: "cider",
},
],
};
I keep getting this error:
There was an error with sending the email
[Error: ENOENT: no such file or directory, open '/mnt/stf/coding/donation-platform/.next/server/pages/api/mastercard.png'] {
errno: -2,
code: 'ESTREAM',
syscall: 'open',
path: '/mnt/stf/coding/app/.next/server/pages/api/mastercard.png',
command: 'API'
}
I tried moving the image to different directories and changing the path a few times, but nothing works. What is the correct path to images from public
directory? (or where to place the images to get them?)