Skip to content

Commit

Permalink
🔧 Add SMTP_SSL option for older SMTP servers (#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 a4358db commit 2f02756
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ SMTP_USER=
SMTP_PASSWORD=
EMAILS_FROM_EMAIL=info@example.com
SMTP_TLS=True
SMTP_SSL=False
SMTP_PORT=587

# Postgres
Expand Down
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 2f02756

Please sign in to comment.