Hi folks,
I have a weird problem with my Astro site when deployed to Netlify. Until last week everything was working perfectly. I updated an entirely unrelated part of my site, and ran an npm update, and now I have a weird pathing issue.
I am sending emails from my backend using Nodemailer and nodemailer-express-handlebars. Neither of these packages were updated.
import nodemailer from 'nodemailer'
import nodemailerHbs from 'nodemailer-express-handlebars'
import path from 'path'
export const transporter = nodemailer.createTransport({
host: import.meta.env.SMTP_HOST,
port: import.meta.env.SMTP_PORT,
auth: {
user: import.meta.env.SMTP_USER,
pass: import.meta.env.SMTP_PW
}
})
// Configure nodemailer-express-handlebars
const hbsOptions = {
viewEngine: {
extName: '.hbs',
partialsDir: path.resolve('./src/lib/email_templates'),
defaultLayout: false
},
viewPath: path.resolve('./src/lib/email_templates'),
extName: '.hbs'
}
transporter.use('compile', nodemailerHbs(hbsOptions))
This works fine on my dev server, and worked fine on Netlify until recently.
Now when my app tries to send emails, I get an error:
ERROR Error sending email: [Error: ENOENT: no such file or directory, open '/var/task/src/lib/email_templates/orderConfirmation.hbs'] { errno: -2, code: 'ENOENT', syscall: 'open', path: '/var/task/src/lib/email_templates/orderConfirmation.hbs' }
This happens for every email template. I haven’t changed this code or my file structure since it last worked. The only thing that has changed has been some updates to the Astro Netlify adapter.
Any ideas?