from fastapi_pundra.common.mailer.mail import send_mail
await send_mail(
subject="Hello, World!",
to=["test@example.com"],
template_name="welcome_email.html",
context={"name": "John Doe"},
)from fastapi_pundra.common.mailer.mail import send_mail_background
await send_mail_background(
background_tasks=background_tasks,
subject="Hello, World!",
to=["test@example.com"],
template_name="welcome_email.html",
context={"name": "John Doe"},
)- if you want to send mail in background, you can use
background_tasksin your route
from fastapi import BackgroundTasks
@router.post("/users/registration")
@dto(UserCreateSchema)
async def registration(request: Request, background_tasks: BackgroundTasks) -> JSONResponse:
...note: background_tasks paramter will be after
requestparameter in your route