4

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.

Leonardo
  • 451
  • 3
  • 13

2 Answers2

4

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.

Mats Mikkel Rummelhoff
  • 22,361
  • 3
  • 38
  • 69
  • Where can one find all the possible environment variables related to SMTP in craft? – BrokenCode Dec 14 '22 at 16:23
  • @BrokenCode Anything in particular you're looking for? There aren't any dedicated environment variables related to SMTP per se; only environment variable support for most of the SMTP settings. The actual environment variables can be named anything. – Mats Mikkel Rummelhoff Dec 14 '22 at 16:56
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);