Flask Async Mail
flask-async-mail is a Flask extension that simplifies sending emails asynchronously using Celery. This library is designed to help you handle email sending as a background task, improving the performance and responsiveness of your Flask applications.
Installation
pip install flask-async-mail
Usage
First, initialize the extension in your Flask application:
from flask import Flask
from flask_async_mail import FlaskCelery
app = Flask(__name__)
celery = FlaskCelery()
celery.init_app(app)
Then, configure your email settings:
app.config.update(
CELERY_BROKER_URL = "redis://localhost:6379/0"
CELERY_RESULT_BACKEND = "redis://localhost:6379/0"
SMTP_HOST='smtp.example.com',
PORT=587,
USE_TLS=True,
USE_SSL=False,
SENDER='your-email@example.com',
PASSWORD='your-password'
)
using celery as decorator
from flask_async_mail.email_service import SendMail
mailer = SendMail(app.config.items())
@celery.task
async def send_client_mail():
await mailer.send_email(
subject="Hello, I'am FlaskCelery",
recipient=["flaskcelery@example.com"],
content="""
<html>
<body>
<h1>Hello user, This is FlaskCelery Library Update</h1>
</body>
</html>
""",
content_type="html"
)
run command
celery -A task.celery worker --loglevel=info
Release files for flask-async-mail 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flask_async_mail-0.1.0.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flask_async_mail-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.9 kB
Release files / flask_async_mail-0.1.0.tar.gz
| Download URL | flask_async_mail-0.1.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
41ec8ee438edb0bef77c3f432030c920f5689a621af8ba67431cd592f354e157
|
|
BLAKE2b-256 checksum How to use checksums |
14c16561aacbb2a503f3ab9c91f5154832b9628c03ec542c963323c5ea38e084
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.1 CPython/3.13.1 Windows/10
|
Release files / flask_async_mail-0.1.0-py3-none-any.whl
| Download URL | flask_async_mail-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
75856e79fc67ec9c2efef4f263fe8d609fbe5d5e15b5765b740c26adbd712ae4
|
|
BLAKE2b-256 checksum How to use checksums |
857af6b4ec10078018cb01ce2b671ab84ee0d7102851984c12eeabd92f98bb3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.1 CPython/3.13.1 Windows/10
|