Config overrides only work with hard-coded values, cannot use environment variables

Created on 29 January 2022, almost 4 years ago
Updated 10 October 2025, 26 days ago

Problem/Motivation

We typically use environment variables in our local, development, staging and production environments to store credentials for various drupal modules and services, and configure overrides in settings.php to utilize the values stored in environment variables as config override values for different environments.

Every time we configure an environment variable to store anything other than the 'smtp_host', sending mail from the site fails.

Hard-coding those configuration override values in settings.php, however, works.

To make this work unilaterally, requires that we add extensive logic for each hard-coded value that changes per environment, making a standard configuration workflow much more friable.

Steps to reproduce

Configure a config override in settings.php for the 'smtp_port' with a hard-coded value, and reset the cache.
Test sending an email and verify that this is successful.

Set an environment variable called "SMTP_PORT" to the same value as the override value above.
Change the config override in settings.php to read the environment variable instead, using getenv('SMTP_PORT'), and reset the cache.
Test sending an email -- this will fail.

Scratching my head on this one.

πŸ’¬ Support request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States lisa.rae

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024