-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add email backend that behaves like in Django 3.2
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import ssl | ||
|
||
from django.core.mail.backends.smtp import EmailBackend as SMTPBackend | ||
from django.utils.functional import cached_property | ||
|
||
|
||
__all__ = ["OldStyleEmailBackend"] | ||
|
||
|
||
class OldStyleEmailBackend(SMTPBackend): | ||
@cached_property | ||
def ssl_context(self): | ||
if self.ssl_certfile or self.ssl_keyfile: | ||
ssl_context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT) | ||
ssl_context.load_cert_chain(self.ssl_certfile, self.ssl_keyfile) | ||
return ssl_context | ||
else: | ||
ssl_context = ssl.create_default_context() | ||
Check failure Code scanning / SonarCloud Server hostnames should be verified during SSL/TLS connections High
Enable server hostname verification on this SSL/TLS connection. See more on SonarCloud
|
||
ssl_context.check_hostname = False | ||
ssl_context.verify_mode = ssl.CERT_NONE | ||
Check failure Code scanning / SonarCloud Server certificates should be verified during SSL/TLS connections High
Enable server certificate validation on this SSL/TLS connection. See more on SonarCloud
|
||
return ssl_context |