Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Server Based Configuration Overrides

Started by Dom 2 years ago · 0 replies · 216 views
2 years ago

Hey there,

I'm trying to get credentials (SMTP,...) out of the user-folder and I want to define them by environment variables.

For that I tried to create a "user/setup.php" with the following content:

PHP
<?php

return [
    'plugins' => [
        'email' => [
            'mailer' => [
                'smtp' => [
                    'port' => getenv('SMTP_PORT'),
                    'user' => getenv('SMTP_USER'),
                    'password' => getenv('SMTP_PASSWORD')
                ]
            ]
        ]
    ]
];

The issue is (took my quiet some time to find out) that everything I've defined is overwritten again by the email-plugin default-config:

YAML
enabled: true
from:
to:
mailer:
  engine: sendmail
  smtp:
    server: localhost
    port: 25
    encryption: none
    user:
    password:
  sendmail:
    bin: "/usr/sbin/sendmail -bs"
content_type: text/html
debug: false

When I remove, for example "user:" it works as expected.
So, how can I achieve to define such config-values without now altering the email-plugin?

On deploy-pipelines it is very common to work with environment variables, especially when deploying grav as a docker-image.

Thanks!

Suggested topics

Topic Participants Replies Views Activity
Support · by blu3prince, 4 days ago
1 68 4 hours ago
Support · by complanar, 7 days ago
6 157 2 days ago
Support · by Rick Beebe, 7 days ago
2 116 3 days ago
Support · by alex, 5 days ago
2 101 4 days ago
Support · by Marcel, 2 weeks ago
1 152 4 days ago