🔧 Add SMTP_SSL
option for older SMTP servers (#365)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:

committed by
GitHub

parent
a4358db5bc
commit
2f027567c6
1
.env
1
.env
@@ -21,6 +21,7 @@ SMTP_USER=
|
|||||||
SMTP_PASSWORD=
|
SMTP_PASSWORD=
|
||||||
EMAILS_FROM_EMAIL=info@example.com
|
EMAILS_FROM_EMAIL=info@example.com
|
||||||
SMTP_TLS=True
|
SMTP_TLS=True
|
||||||
|
SMTP_SSL=False
|
||||||
SMTP_PORT=587
|
SMTP_PORT=587
|
||||||
|
|
||||||
# Postgres
|
# Postgres
|
||||||
|
@@ -64,6 +64,7 @@ class Settings(BaseSettings):
|
|||||||
)
|
)
|
||||||
|
|
||||||
SMTP_TLS: bool = True
|
SMTP_TLS: bool = True
|
||||||
|
SMTP_SSL: bool = False
|
||||||
SMTP_PORT: int = 587
|
SMTP_PORT: int = 587
|
||||||
SMTP_HOST: str | None = None
|
SMTP_HOST: str | None = None
|
||||||
SMTP_USER: str | None = None
|
SMTP_USER: str | None = None
|
||||||
|
@@ -40,6 +40,8 @@ def send_email(
|
|||||||
smtp_options = {"host": settings.SMTP_HOST, "port": settings.SMTP_PORT}
|
smtp_options = {"host": settings.SMTP_HOST, "port": settings.SMTP_PORT}
|
||||||
if settings.SMTP_TLS:
|
if settings.SMTP_TLS:
|
||||||
smtp_options["tls"] = True
|
smtp_options["tls"] = True
|
||||||
|
elif settings.SMTP_SSL:
|
||||||
|
smtp_options["ssl"] = True
|
||||||
if settings.SMTP_USER:
|
if settings.SMTP_USER:
|
||||||
smtp_options["user"] = settings.SMTP_USER
|
smtp_options["user"] = settings.SMTP_USER
|
||||||
if settings.SMTP_PASSWORD:
|
if settings.SMTP_PASSWORD:
|
||||||
|
Reference in New Issue
Block a user