A Flask extension for sending emails asynchronously with Celery
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flask_async_mail-0.1.0.tar.gz.
File metadata
- Download URL: flask_async_mail-0.1.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.1 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41ec8ee438edb0bef77c3f432030c920f5689a621af8ba67431cd592f354e157
|
|
| MD5 |
6b9e93c2888b9421d3c18d4759ecefa1
|
|
| BLAKE2b-256 |
14c16561aacbb2a503f3ab9c91f5154832b9628c03ec542c963323c5ea38e084
|
File details
Details for the file flask_async_mail-0.1.0-py3-none-any.whl.
File metadata
- Download URL: flask_async_mail-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.1 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75856e79fc67ec9c2efef4f263fe8d609fbe5d5e15b5765b740c26adbd712ae4
|
|
| MD5 |
37da484ec7af160792f042bef519c00a
|
|
| BLAKE2b-256 |
857af6b4ec10078018cb01ce2b671ab84ee0d7102851984c12eeabd92f98bb3b
|