Hi all, a bit new to web development!
I am using Netlify to host my github repo and I am trying to send an attachment via email using nodemailer in my submission-created.js:
let replyMailOptions = {
from: GMAIL,
to: mail,
subject: `My Test Subject`,
html: `<p>a message</p>`,
attachments: {
path: './test.txt'
}
};
but it isn’t locating the file. I’ve tried placing the file under /functions/test.txt, under a subfolder /functions/test/test.txt as well as /assets/test.txt. I’ve tried to view the files under the current folder with
fs.readdir(__dirname, (err, files) => {
files.forEach(file => {
console.log(file);
});
});
I’ve also tried to copy the code from here: netlify-functions-cra-example/read-file.js at master · talves/netlify-functions-cra-example · GitHub but I am getting file not found. Specifically - "Invoke Error {“errorType”:“Error”,“errorMessage”:“Cannot find module ‘./test.txt’\n”
I keep going down rabbit holes and not sure which path leads me to what I want. Some of these examples being: build configurations (something about my relative/absolute paths?), Netlify’s “backend” options, large media, site generators and I’m getting overwhelmed and feel like I might be overcomplicating a simple solution.
Any help is much appreciated!