I have an issue with environment variables on Vercel.
Everything works perfectly locally, including when I use a .env
file in github to configure my environment variables. However, when I set these variables directly in Vercel’s environment variables interface, the application stops working correctly.
For context:
- I am using an SMTP server through IONOS on port 465.
- The required variables, such as the host, port, username, and password, are defined in a local
.env
file as follows:SMTP_HOST=smtp.ionos.fr SMTP_PORT=456 SMTP_USER=my_username SMTP_PASS=my_password
- Locally, everything works without any issues.
On Vercel, I configured these same variables in the Environment Variables section. However, after deploying the application, the email-sending functionality using SMTP no longer works.
I verified the following:
- The names of the environment variables in Vercel exactly match those in my code.
- I restarted the application after setting the variables in Vercel.
- I confirmed that the variables are accessible in production using
console.log(process.env.VARIABLE)
for debugging.
Despite this, the issue persists, and the logs on Vercel or the errors returned are not clear enough to identify the root cause.
Does anyone know if additional configuration is required to use SMTP with Vercel? Are there specific steps I might be missing? Could there be a limitation or a known issue with Vercel and SMTP via IONOS?
The project is built with Next.js, and any guidance would be greatly appreciated. Thank you!