forked from ui/django-post_office
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into database_mutex
- Loading branch information
Showing
47 changed files
with
1,512 additions
and
797 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
commit-message: | ||
prefix: "chore(ci): " | ||
groups: | ||
github-actions: | ||
patterns: | ||
- "*" | ||
open-pull-requests-limit: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Publish django-post_office | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
publish: | ||
name: "Publish release" | ||
runs-on: "ubuntu-latest" | ||
|
||
environment: | ||
name: deploy | ||
|
||
strategy: | ||
matrix: | ||
python-version: ["3.9"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install build --user | ||
- name: Build 🐍 Python 📦 Package | ||
run: python -m build --sdist --wheel --outdir dist/ | ||
- name: Publish 🐍 Python 📦 Package to PyPI | ||
if: startsWith(github.ref, 'refs/tags') | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN_POST_OFFICE }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
Django Post Office is a simple app to send and manage your emails in | ||
Django. Some awesome features are: | ||
|
||
- Designed to scale, handles millions of emails efficiently | ||
- Allows you to send email asynchronously | ||
- Multi backend support | ||
- Supports HTML email | ||
|
@@ -12,8 +13,7 @@ Django. Some awesome features are: | |
- Built in scheduling support | ||
- Works well with task queues like [RQ](http://python-rq.org) or | ||
[Celery](http://www.celeryproject.org) | ||
- Uses multiprocessing (and threading) to send a large number of | ||
emails in parallel | ||
- Uses multiprocessing and threading to send a large number of emails in parallel | ||
|
||
## Dependencies | ||
|
||
|
@@ -27,10 +27,11 @@ will otherwise be stripped for security reasons. | |
|
||
## Installation | ||
|
||
[![Build | ||
Status](https://travis-ci.org/ui/django-post_office.png?branch=master)](https://travis-ci.org/ui/django-post_office) [![PyPI version](https://img.shields.io/pypi/v/django-post_office.svg)](https://pypi.org/project/django-post_office/) ![Software license](https://img.shields.io/pypi/l/django-post_office.svg) | ||
[![Build Status](https://github.com/ui/django-post_office/actions/workflows/test.yml/badge.svg)](https://github.com/ui/django-post_office/actions) | ||
[![PyPI](https://img.shields.io/pypi/pyversions/django-post_office.svg)]() | ||
[![PyPI version](https://img.shields.io/pypi/v/django-post_office.svg)](https://pypi.python.org/pypi/django-post_office) | ||
[![PyPI](https://img.shields.io/pypi/l/django-post_office.svg)]() | ||
|
||
Install from PyPI (or [manually download from PyPI](http://pypi.python.org/pypi/django-post_office)): | ||
|
||
```sh | ||
pip install django-post_office | ||
|
@@ -311,6 +312,7 @@ inlined images, use the following code snippet: | |
|
||
```python | ||
from django.core.mail import EmailMultiAlternatives | ||
from django.template.loader import get_template | ||
|
||
subject, body = "Hello", "Plain text body" | ||
from_email, to_email = "[email protected]", "[email protected]" | ||
|
@@ -328,6 +330,7 @@ plain text body, use this code snippet: | |
|
||
```python | ||
from django.core.mail import EmailMultiAlternatives | ||
from django.template.loader import get_template | ||
|
||
subject, from_email, to_email = "Hello", "[email protected]", "[email protected]" | ||
template = get_template('email-template-name.html', using='post_office') | ||
|
@@ -409,15 +412,29 @@ put in Django's `settings.py` to fine tune `post-office`'s behavior. | |
|
||
### Batch Size | ||
|
||
If you may want to limit the number of emails sent in a batch (sometimes | ||
If you may want to limit the number of emails sent in a batch ( | ||
useful in a low memory environment), use the `BATCH_SIZE` argument to | ||
limit the number of queued emails fetched in one batch. | ||
limit the number of queued emails fetched in one batch. `BATCH_SIZE` defaults to 100. | ||
|
||
```python | ||
# Put this in settings.py | ||
POST_OFFICE = { | ||
... | ||
'BATCH_SIZE': 50, | ||
'BATCH_SIZE': 100, | ||
} | ||
``` | ||
|
||
Version 3.8 introduces a companion setting called `BATCH_DELIVERY_TIMEOUT`. This setting | ||
specifies the maximum time allowed for each batch to be delivered, this is useful to guard against | ||
cases where delivery process never terminates. Defaults to 180. | ||
|
||
If you send a large number of emails in a single batch on a slow connection, consider increasing this number. | ||
|
||
```python | ||
# Put this in settings.py | ||
POST_OFFICE = { | ||
... | ||
'BATCH_DELIVERY_TIMEOUT': 180, | ||
} | ||
``` | ||
|
||
|
@@ -435,6 +452,17 @@ POST_OFFICE = { | |
} | ||
``` | ||
|
||
### Lock File Name | ||
The default lock file name is `post_office`, but this can be altered by setting `LOCK_FILE_NAME` in the configuration. | ||
|
||
```python | ||
# Put this in settings.py | ||
POST_OFFICE = { | ||
... | ||
'LOCK_FILE_NAME': 'custom_lock_file', | ||
} | ||
``` | ||
|
||
### Override Recipients | ||
|
||
Defaults to `None`. This option is useful if you want to redirect all | ||
|
@@ -550,7 +578,7 @@ POST_OFFICE = { | |
} | ||
``` | ||
|
||
`CONTEXT_FIELD_CLASS` defaults to `jsonfield.JSONField`. | ||
`CONTEXT_FIELD_CLASS` defaults to `django.db.models.JSONField`. | ||
|
||
### Logging | ||
|
||
|
@@ -665,7 +693,7 @@ Attachments are not supported with `mail.send_many()`. | |
To run the test suite: | ||
|
||
```python | ||
`which django-admin.py` test post_office --settings=post_office.test_settings --pythonpath=. | ||
`which django-admin` test post_office --settings=post_office.test_settings --pythonpath=. | ||
``` | ||
|
||
You can run the full test suite for all supported versions of Django and Python with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import django | ||
from ast import literal_eval | ||
from os.path import dirname, join | ||
|
||
with open(join(dirname(__file__), 'version.txt'), 'r') as fh: | ||
with open(join(dirname(__file__), 'version.txt')) as fh: | ||
VERSION = literal_eval(fh.read()) | ||
|
||
from .backends import EmailBackend | ||
|
||
if django.VERSION < (3, 2): # pragma: no cover | ||
default_app_config = 'post_office.apps.PostOfficeConfig' |
Oops, something went wrong.