This commit is contained in:
retoor 2025-11-11 15:20:14 +01:00
parent 3b57f4cbf6
commit d957968e6f
2 changed files with 9 additions and 8 deletions

View File

@ -60,12 +60,12 @@ class EmailService:
async def _send_email_task(self, task: EmailTask): async def _send_email_task(self, task: EmailTask):
"""Send a single email task""" """Send a single email task"""
if not settings.SMTP_SERVER or not settings.SMTP_USERNAME or not settings.SMTP_PASSWORD: if not settings.SMTP_HOST or not settings.SMTP_USERNAME or not settings.SMTP_PASSWORD:
print("SMTP not configured, skipping email send") print("SMTP not configured, skipping email send")
return return
msg = MIMEMultipart('alternative') msg = MIMEMultipart('alternative')
msg['From'] = settings.SMTP_FROM_EMAIL msg['From'] = settings.SMTP_SENDER_EMAIL
msg['To'] = task.to_email msg['To'] = task.to_email
msg['Subject'] = task.subject msg['Subject'] = task.subject
@ -81,7 +81,7 @@ class EmailService:
try: try:
if settings.SMTP_PORT == 465: if settings.SMTP_PORT == 465:
async with aiosmtplib.SMTP( async with aiosmtplib.SMTP(
hostname=settings.SMTP_SERVER, hostname=settings.SMTP_HOST,
port=settings.SMTP_PORT, port=settings.SMTP_PORT,
username=settings.SMTP_USERNAME, username=settings.SMTP_USERNAME,
password=settings.SMTP_PASSWORD, password=settings.SMTP_PASSWORD,
@ -91,7 +91,7 @@ class EmailService:
print(f"Email sent to {task.to_email}") print(f"Email sent to {task.to_email}")
else: else:
async with aiosmtplib.SMTP( async with aiosmtplib.SMTP(
hostname=settings.SMTP_SERVER, hostname=settings.SMTP_HOST,
port=settings.SMTP_PORT, port=settings.SMTP_PORT,
) as smtp: ) as smtp:
await smtp.starttls() await smtp.starttls()

View File

@ -18,11 +18,12 @@ class Settings(BaseSettings):
S3_SECRET_ACCESS_KEY: str | None = None S3_SECRET_ACCESS_KEY: str | None = None
S3_ENDPOINT_URL: str | None = None S3_ENDPOINT_URL: str | None = None
S3_BUCKET_NAME: str = "rbox-storage" S3_BUCKET_NAME: str = "rbox-storage"
SMTP_SERVER: str | None = None SMTP_HOST: str = "mail.example.com"
SMTP_PORT: int = 587 SMTP_PORT: int = 587
SMTP_USERNAME: str | None = None SMTP_USERNAME: str = "noreply@example.com"
SMTP_PASSWORD: str | None = None SMTP_PASSWORD: str = "your-smtp-password"
SMTP_FROM_EMAIL: str = "no-reply@example.com" SMTP_USE_TLS: bool = True
SMTP_SENDER_EMAIL: str = "noreply@example.com"
TOTP_ISSUER: str = "RBox" TOTP_ISSUER: str = "RBox"
STRIPE_SECRET_KEY: str = "" STRIPE_SECRET_KEY: str = ""
STRIPE_PUBLISHABLE_KEY: str = "" STRIPE_PUBLISHABLE_KEY: str = ""