1

I'm trying to setup different mail settings per environment. Here is my mail component that I'm defining in config/app.php:

'components' => [
    'mailer' => function() {
        // Get the stored email settings
        $settings = Craft::$app->systemSettings->getEmailSettings();

        // Override the transport adapter class
        $settings->transportType = craft\mail\transportadapters\Smtp::class;

        // Override the transport adapter settings
        $settings->transportSettings = [
            'host'              => 'localhost',
            'port'              => '1025',
            'useAuthentication' => false,
            'encryptionMethod'  => null,
            'timeout'           => '10',
        ];

        return craft\helpers\MailerHelper::createMailer($settings);
    },
],

How do I ensure this only applies to development environments? Multi-environment doesn't seem to work like it does for config/general.php and there's no multi-environment example in the relevant documentation. Brandon's Github comment here suggests that this is possible. Thanks.

1 Answer 1

2

To get this to work, have a look at the format of the general.php config file.

The key is to include the '*'=>[] at the start.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.