3

The official Craft documentation says it is possible to set the "Encryption Method (SMTP)" , Snipped from the documentation, with an Environment Variable.

I think i am missing something but i cant seem to find the exact .env Variable Name Craft is expecting for this setting.

2 Answers 2

3

You can name the environment variable whatever you want. The trick is that the variable's value needs to be either none, ssl or tls (i.e. the three options that are supported for the "Encryption Method" setting), for it to be selectable for that setting.

For example, if you add a variable called SMTP_ENCRYPTION_METHOD to your .env file, and set its value to ssl (i.e. SMTP_ENCRYPTION_METHOD=ssl), that variable will show up as a selectable option for the "Encryption Method" setting:

enter image description here

Note that the "Use authentication" setting has the same behaviour; any and all environment variables with a value set to one of these settings' supported options (yes, no, true, false, on, off, 0 or 1, for the "Use authentication" setting) will be selectable, regardless of the actual variable name.

Edit: Environment variable support for the Encryption Method setting was only added in Craft 3.7.22, so make sure you're on at least that version.

1

In the CP, I don't think that's an option. The name of the variable is encryptionMethod and its value comes from database (encryptionMethod). It doesn't have an accessible value from your .env file.

In your PHP code yes you can do that. You will just have to use Craft::parseEnv($yourVariable);

3
  • 1
    It was added quite recently in Craft 3.7.22 :) Dec 22, 2021 at 23:09
  • 1
    No wonder! I guess I need to update. Dev is running 3.6.18. And thank you for that! Dec 22, 2021 at 23:10
  • 1
    Added a note about that to the my answer, since it's so recent – OP might be on an older version, too :) Dec 22, 2021 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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