Email Integration File Attachment Error

I am using the email integration functionality to send mail via Mailgun. Everything was working fine until I tried to include a file attachment. While it worked fine locally using the Netlify CLI, it does not work in production and gives the following error:

Feb 13, 05:34:32 PM: INIT_START Runtime Version: nodejs:16.v11 Runtime Version ARN: arn:aws:lambda:us-east-1::runtime:ee071345fbee0f4751fcbcd47a5784052d8f7d4256ca7f31e6056b294cee515c
Feb 13, 05:34:32 PM: 41f7e13b ERROR Invoke Error {“errorType”:“Error”,“errorMessage”:“ENOENT: no such file or directory, open ‘./assets/downloads/price-sheet-studio-539.pdf’”,“code”:“ENOENT”,“errno”:-2,“syscall”:“open”,“path”:“./assets/downloads/price-sheet-studio-539.pdf”,“stack”:[“Error: ENOENT: no such file or directory, open ‘./assets/downloads/price-sheet-studio-539.pdf’”," at Object.openSync (node:fs:585:3)“,” at Object.readFileSync (node:fs:453:35)“,” at Runtime.handler (/var/task/netlify/functions/submission-created.js:5591:34)“,” at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1089:29)"]}
Feb 13, 05:34:32 PM: 41f7e13b Duration: 6.65 ms Memory Usage: 63 MB Init Duration: 177.93 ms

My site name is “studio-539-flowers.netlify.app” and I don’t have any build settings in place. I have tried a bunch of changes to the filename and path and also tried a full URL reference (https://studio-539-flowers.netlify.app/assets/downloads/price-sheet-studio-539.pdf) and nothing fixed it.

Hi @intrepidws :wave:t6: ,

Welcome to the forums. Have you given this guide a read first?

Yup, that’s where I got my code from :slight_smile:

Weird it might be configured weirdly. I’m not sure wher eot go from here can you share your repo?

Hi @intrepidws, would you be able to let us know what version of the email plugin you are running and specifically the one that you can see is being run in the build logs?

I have a hunch that changing the included_files setting for your function may resolve this. This article may be helpful How to Include Files in Netlify Serverless Functions

Hi @thorleylt - I am using version 1.0.3. I was able to fix my issue by changing the included_files setting for my function, as you suggested. Thanks for your help!

I don’t know if you have any input to the docs, but I think this entry would be improved if it mentioned something about the need to include the file as you’ve described. Currently it doesn’t say anything about that.