Skip to content

Commit

Permalink
🔧 Add SMTP_SSL option for older SMTP servers (fastapi#365)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
  • Loading branch information
Metrea and tiangolo authored Mar 12, 2024
1 parent 7e50245 commit 556f28b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def SQLALCHEMY_DATABASE_URI(self) -> PostgresDsn:
)

SMTP_TLS: bool = True
SMTP_SSL: bool = False
SMTP_PORT: int = 587
SMTP_HOST: str | None = None
SMTP_USER: str | None = None
Expand Down
2 changes: 2 additions & 0 deletions backend/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def send_email(
smtp_options = {"host": settings.SMTP_HOST, "port": settings.SMTP_PORT}
if settings.SMTP_TLS:
smtp_options["tls"] = True
elif settings.SMTP_SSL:
smtp_options["ssl"] = True
if settings.SMTP_USER:
smtp_options["user"] = settings.SMTP_USER
if settings.SMTP_PASSWORD:
Expand Down

0 comments on commit 556f28b

Please sign in to comment.