Fix boolean parsing of SMTP configuration from environment variables. #5861
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the previous implementation, there was an issue with parsing the boolean values of the SMTP configuration from environment variables. The use of bool() on the string returned by
os.getenv()
caused bothMAIL_USE_TLS
andMAIL_USE_SSL
to be set to True, regardless of the actual environment variable values.This PR fixes the issue with boolean parsing. By explicitly converting the environment variable values to integers using int() and providing default string values of "1" for
TM_SMTP_USE_TLS
and "0" forTM_SMTP_USE_SSL
, the correct boolean values are obtained. This ensures that the SMTP configuration reflects the intended TLS and SSL settings based on the environment variables provided.With this fix, the
MAIL_USE_TLS
andMAIL_USE_SSL
variables will be set to True only if the environment variables are set to non-zero values, and False otherwise.