Sending email only works on local server

I’m creating a simple contact form for a client using Gatsby. Name, email and message. I’m using Emailjs and hosting on Netlify. When I run the Gatsby site in development mode and test the form, everything works and an email is sent. But when it is hosted on Netlify it doesn’t send. The console log error says: Public key is required from your email js account.
I have added all the api keys and tokens for Emailjs in the environment variables on Netlify. I’ve triple checked all api keys letter by letter and it’s correct.

What am I missing? Why is it working in local server but not on Netlify?

[SOLVED]
I figured out that all Gatsby variables need to be prefixed with GATSBY_, similar to how React env variables work.

I read the Netlify docs here: