Nodemailer plugin config can't read ENV values after deployment

I have nodemailer plugin installed and configured. Everything runs smoothly on localhost but when I deploy the application into Digital Ocean the configuration can’t read ENV variables and only serves defaults.

“scripts”: {
“build”: “strapi build”,
“db:stop”: “docker-compose stop”,
“db:up”: “docker-compose up -d”,
“develop”: “strapi develop”,
“start”: “strapi start”,
“strapi”: “strapi”
“dependencies”: {
@strapi/plugin-i18n”: “4.15.5”,
@strapi/plugin-users-permissions”: “4.15.5”,
@strapi/provider-email-nodemailer”: “4.15.5”,
@strapi/strapi”: “4.15.5”,
“luxon”: “3.4.4”,
“mysql”: “2.18.1”,
“react”: “18.2.0”,
“react-dom”: “18.2.0”,
“react-router-dom”: “6.21.0”,
“styled-components”: “6.1.1”,
“zod”: “3.22.4”
“devDependencies”: {
@types/luxon”: “3.3.7”
“engines”: {
“node”: “>=18.0.0 <=20.x.x”,
“npm”: “>=6.0.0”

export default ({ env }) => ({
email: {
config: {
provider: “nodemailer”,
providerOptions: {
host: env(“SMTP_HOST”),
port: env(“SMTP_PORT”, 1234),
secure: false,
auth: {
user: env(“SMTP_USER”),
pass: env(“SMTP_PASSWORD”),
tls: {
ciphers: “SSLv3”,
settings: {
defaultFrom: env(“SMTP_FROM”),
defaultReplyTo: env(“SMTP_FROM”),

This topic has been created from a Discord post (1214486998627389490) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

Error it keeps giving (with default host and whatever default values instead of ENV values):

[2024-03-05 10:04:53.390] error: Couldn't send test email: connect ECONNREFUSED
Error: Couldn't send test email: connect ECONNREFUSED
    at Object.test (/opt/app/node_modules/@strapi/plugin-email/dist/server/index.js:173:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async returnBodyMiddleware (/opt/app/node_modules/@strapi/strapi/dist/services/server/compose-endpoint.js:42:18)
    at async policiesMiddleware (/opt/app/node_modules/@strapi/strapi/dist/services/server/policy.js:15:5)
    at async /opt/app/node_modules/@strapi/strapi/dist/services/server/compose-endpoint.js:27:12
    at async /opt/app/node_modules/@strapi/strapi/dist/middlewares/body.js:45:9
    at async /opt/app/node_modules/@strapi/strapi/dist/middlewares/logger.js:6:5
    at async /opt/app/node_modules/@strapi/strapi/dist/middlewares/powered-by.js:9:5
    at async cors (/opt/app/node_modules/@koa/cors/index.js:107:16)
    at async /opt/app/node_modules/@strapi/strapi/dist/middlewares/errors.js:8:7```