You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I'm considering using red-mail to send emails in a backend application. Since connecting to the SMTP server is an I/O blocking operation, I would like to make use of async to avoid blocking other requests while the SMTP server or network are slow.
Describe the solution you'd like
I would like to be able to use red-mail in the following way.
fromredmailimportEmailSenderfromfastapiimportFastAPIapp=FastAPI()
@app.post("/send-email")asyncdefsend_email() ->dict[str, str]:
"""Send an example email when this API endpoint is requested."""email=EmailSender(host='localhost', port=0) # Real SMTP server would be on a remote network# By awaiting here, we allow other requests to be processed while waiting for I/O# Of course, using a different method name like `asend` would also be fine in order to keep the synchronous methods backwards compatibleawaitemail.send(
subject='async support in red-mail',
sender="[email protected]",
receivers=['[email protected]']
)
return {"status": "OK"}
Describe alternatives you've considered
Without async support I'd have to introduce additional complexity to get the same results.
manually creating threads or processes
fork red-mail and make it async
introduce a task queue and hand over email sending tasks
@Miksus If you're open to this, please let me know :) Thank you!
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I'm considering using
red-mail
to send emails in a backend application. Since connecting to the SMTP server is an I/O blocking operation, I would like to make use ofasync
to avoid blocking other requests while the SMTP server or network are slow.Describe the solution you'd like
I would like to be able to use
red-mail
in the following way.Describe alternatives you've considered
Without
async
support I'd have to introduce additional complexity to get the same results.red-mail
and make it async@Miksus If you're open to this, please let me know :) Thank you!
The text was updated successfully, but these errors were encountered: