Error using environment variable for email setting I'm trying to create an environment variable for email settings, but it doesn't work. Here is my email setting at config/general.php

'dev' =&gt; [
    '@host' =&gt; 'host',
    '@port' =&gt; '587',
    '@username' =&gt; 'user@user',
    '@password' =&gt; 'passwrod'
],




I have also tried before to configure the email setting using this way at config/app.php, but it doesn't work.

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

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

        // Override the transport adapter settings
        $settings-&gt;transportSettings = [
            'host' =&gt; 'host',
            'port' =&gt; '587',
            'useAuthentication' =&gt; true,
            'username' =&gt; 'user@user',
            'password' =&gt; 'passwrod'
        ];

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


Am I doing anything wrong?
I think you're getting a few conventions mixed up.

Using an @ is typically reserved for aliases https://docs.craftcms.com/v3/config/environments.html#using-aliases-in-control-panel-settings

What you're probably looking for is environment variables in your .env file.

You could set:

EMAIL_HOST=myhost
EMAIL_PORT=myport
EMAIL_USERNAME=myusername
EMAIL_PASSWORD=mypassword


Then from Settings->Email in the control panel, you can reference them with $ https://docs.craftcms.com/v3/config/environments.html#control-panel-settings

$EMAIL_HOST
$EMAIL_PORT
$EMAIL_USERNAME
$EMAIL_PASSWORD