Search code examples
next.jsnodemailer

Nodemailer with Next.js


Hello I'm using nodemailer with next, I'm trying to include an image in the email but keep getting this error

err: [Error: ENOENT: no such file or directory, open '/images/welcome.png'] {
    errno: -2,
    code: 'ESTREAM',
    syscall: 'open',
    path: '/images/welcome.png',
    command: 'API'
  }

any idea how can I successfully include image in one the Next /api routes?


Solution

  • You're trying to find the image directory from the root of the project instead that use like this

    path: path.join(process.cwd(), `../static/images/your_image.png`)