Skip to content

Commit 7adb765

Browse files
committed
Fixed SMTP TLS issue
SMTP options for TLS must be `ssl`. Ref https://python-emails.readthedocs.io/en/latest/ #8, from @raouldo
1 parent 5788313 commit 7adb765

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

cookiecutter.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"first_superuser": "admin@{{cookiecutter.domain_main}}",
1515
"first_superuser_password": "changethis",
1616
"backend_cors_origins": "[\"http://localhost\", \"http://localhost:4200\", \"http://localhost:3000\", \"http://localhost:8080\", \"https://localhost\", \"https://localhost:4200\", \"https://localhost:3000\", \"https://localhost:8080\", \"http://dev.{{cookiecutter.domain_main}}\", \"https://{{cookiecutter.domain_staging}}\", \"https://{{cookiecutter.domain_main}}\", \"http://local.dockertoolbox.tiangolo.com\", \"http://localhost.tiangolo.com\"]",
17+
"smtp_tls": true,
1718
"smtp_port": "587",
1819
"smtp_host": "",
1920
"smtp_user": "",

{{cookiecutter.project_slug}}/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ SECRET_KEY={{cookiecutter.secret_key}}
2222
TOTP_SECRET_KEY={{cookiecutter.totp_secret_key}}
2323
FIRST_SUPERUSER={{cookiecutter.first_superuser}}
2424
FIRST_SUPERUSER_PASSWORD={{cookiecutter.first_superuser_password}}
25-
SMTP_TLS=True
25+
SMTP_TLS={{cookiecutter.smtp_tls}}
2626
SMTP_PORT={{cookiecutter.smtp_port}}
2727
SMTP_HOST={{cookiecutter.smtp_host}}
2828
SMTP_USER={{cookiecutter.smtp_user}}
2929
SMTP_PASSWORD={{cookiecutter.smtp_password}}
3030
EMAILS_FROM_EMAIL={{cookiecutter.smtp_emails_from_email}}
3131
EMAILS_FROM_NAME={{cookiecutter.smtp_emails_from_name}}
32-
EMAILS_TO_EMAIL=={{cookiecutter.smtp_emails_to_email}}
32+
EMAILS_TO_EMAIL={{cookiecutter.smtp_emails_to_email}}
3333

3434
USERS_OPEN_REGISTRATION=True
3535

{{cookiecutter.project_slug}}/backend/app/app/utilities/email.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def send_email(
2323
)
2424
smtp_options = {"host": settings.SMTP_HOST, "port": settings.SMTP_PORT}
2525
if settings.SMTP_TLS:
26-
smtp_options["tls"] = True
26+
# https://python-emails.readthedocs.io/en/latest/
27+
smtp_options["ssl"] = True
2728
if settings.SMTP_USER:
2829
smtp_options["user"] = settings.SMTP_USER
2930
if settings.SMTP_PASSWORD:

{{cookiecutter.project_slug}}/cookiecutter-config-file.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ default_context:
1111
first_superuser: '{{ cookiecutter.first_superuser }}'
1212
first_superuser_password: '{{ cookiecutter.first_superuser_password }}'
1313
backend_cors_origins: '{{ cookiecutter.backend_cors_origins }}'
14+
smtp_tls: '{{ cookiecutter.smtp_tls }}'
1415
smtp_port: '{{ cookiecutter.smtp_port }}'
1516
smtp_host: '{{ cookiecutter.smtp_host }}'
1617
smtp_user: '{{ cookiecutter.smtp_user }}'

0 commit comments

Comments
 (0)