Skip to content

Commit 2f26f76

Browse files
committed
Merge remote-tracking branch 'upstream/master' into database_mutex
2 parents ebd654c + a04ba1a commit 2f26f76

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1512
-797
lines changed

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
commit-message:
8+
prefix: "chore(ci): "
9+
groups:
10+
github-actions:
11+
patterns:
12+
- "*"
13+
open-pull-requests-limit: 1

.github/workflows/publish.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish django-post_office
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
publish:
10+
name: "Publish release"
11+
runs-on: "ubuntu-latest"
12+
13+
environment:
14+
name: deploy
15+
16+
strategy:
17+
matrix:
18+
python-version: ["3.9"]
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
python -m pip install build --user
30+
- name: Build 🐍 Python 📦 Package
31+
run: python -m build --sdist --wheel --outdir dist/
32+
- name: Publish 🐍 Python 📦 Package to PyPI
33+
if: startsWith(github.ref, 'refs/tags')
34+
uses: pypa/gh-action-pypi-publish@master
35+
with:
36+
password: ${{ secrets.PYPI_API_TOKEN_POST_OFFICE }}

.github/workflows/test.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,47 @@ name: Test
22

33
on:
44
push:
5-
branches: [ master ]
65
pull_request:
7-
branches: [ master ]
86

97
permissions:
108
contents: read
119

12-
jobs:
10+
jobs:
11+
ruff-format:
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 1
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: chartboost/ruff-action@v1
17+
with:
18+
version: 0.4.8
19+
args: 'format --check'
1320

1421
build:
1522
runs-on: ubuntu-latest
1623
name: Python${{ matrix.python-version }}/Django${{ matrix.django-version }}
1724
strategy:
1825
matrix:
19-
python-version: ["3.9"]
20-
django-version: ["3.2.16", "4.0.8", "4.1.3"]
26+
python-version: ["3.9", "3.10", "3.11", "3.12"]
27+
django-version: ["4.2", "5.0"]
28+
exclude:
29+
- python-version: "3.9"
30+
django-version: "5.0"
31+
2132

2233
steps:
23-
- uses: actions/checkout@v3
34+
- uses: actions/checkout@v4
2435

2536
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v4.2.0
37+
uses: actions/setup-python@v5
2738
with:
2839
python-version: ${{ matrix.python-version }}
2940

3041
- name: Install dependencies
3142
run: |
3243
python -m pip install --upgrade pip
33-
pip install django==${{ matrix.django-version }}
34-
pip install jsonfield pytz
44+
pip install "Django~=${{ matrix.django-version }}.0"
3545
3646
- name: Run Test
3747
run: |
38-
`which django-admin` test post_office --settings=post_office.test_settings --pythonpath=.
48+
`which django-admin` test post_office --settings=post_office.test_settings --pythonpath=.

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
Changelog
22
=========
33

4+
Version 3.9.0 (2024-06-19)
5+
--------------------------
6+
* Added a new `LOCK_FILE_NAME` which lets you change post office's lock file name. Thanks @mogost!
7+
* Fixes a bug where `email_queued` signal is not sent in certain cases. Thanks @diesieben07!
8+
* Fixes an issue where attachment admin page would not render with large number of emails. Thanks @petrprikryl!
9+
* Fixes a crash when email instances are made with context, but without a template. Thanks @pacahon!
10+
* Other miscellaneous fixes and house keeping tasks by @mogost!
11+
12+
Version 3.8.0 (2023-10-22)
13+
--------------------------
14+
* Added `BATCH_DELIVERY_TIMEOUT` that specifies the maximum time allowed for each batch to be delivered. Defaults to 180 seconds. Thanks @selwin!
15+
16+
Version 3.7.1 (2023-08-08)
17+
--------------------------
18+
* Optimized a queryset in `get_queued()` that doesn't use indexes in Postgres. Thanks @marsha97!
19+
* Removed `date_hierarchy` option which causes admin to load slowly on DBs with a large number of emails. Thanks @selwin!
20+
* Optimized `cleanup_expired_mails()` so that deletes emails in smaller batches. Thanks @marsha97!
21+
22+
Version 3.7.0 (2023-05-30)
23+
--------------------------
24+
* Changed JSON columns to use Django's `JSONField` and drop `jsonfield` dependency. Thanks @jrief!
25+
* Fixed saving HTML emails that have `quoted_printable`. Thanks @gabn88!
26+
* Fixes an issue where emails are rendered without context in Django's admin interface. Thanks @zagl!
27+
* This version no longer supports Django 3.1.
28+
429
Version 3.6.3 (2022-10-27)
530
--------------------------
631
* Fixed an issue where emails may not be rendered with context. Thanks @zagl!

README.md

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Django Post Office is a simple app to send and manage your emails in
44
Django. Some awesome features are:
55

6+
- Designed to scale, handles millions of emails efficiently
67
- Allows you to send email asynchronously
78
- Multi backend support
89
- Supports HTML email
@@ -12,8 +13,7 @@ Django. Some awesome features are:
1213
- Built in scheduling support
1314
- Works well with task queues like [RQ](http://python-rq.org) or
1415
[Celery](http://www.celeryproject.org)
15-
- Uses multiprocessing (and threading) to send a large number of
16-
emails in parallel
16+
- Uses multiprocessing and threading to send a large number of emails in parallel
1717

1818
## Dependencies
1919

@@ -27,10 +27,11 @@ will otherwise be stripped for security reasons.
2727

2828
## Installation
2929

30-
[![Build
31-
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)
30+
[![Build Status](https://github.com/ui/django-post_office/actions/workflows/test.yml/badge.svg)](https://github.com/ui/django-post_office/actions)
31+
[![PyPI](https://img.shields.io/pypi/pyversions/django-post_office.svg)]()
32+
[![PyPI version](https://img.shields.io/pypi/v/django-post_office.svg)](https://pypi.python.org/pypi/django-post_office)
33+
[![PyPI](https://img.shields.io/pypi/l/django-post_office.svg)]()
3234

33-
Install from PyPI (or [manually download from PyPI](http://pypi.python.org/pypi/django-post_office)):
3435

3536
```sh
3637
pip install django-post_office
@@ -311,6 +312,7 @@ inlined images, use the following code snippet:
311312

312313
```python
313314
from django.core.mail import EmailMultiAlternatives
315+
from django.template.loader import get_template
314316

315317
subject, body = "Hello", "Plain text body"
316318
from_email, to_email = "no-reply@example.com", "john@example.com"
@@ -328,6 +330,7 @@ plain text body, use this code snippet:
328330

329331
```python
330332
from django.core.mail import EmailMultiAlternatives
333+
from django.template.loader import get_template
331334

332335
subject, from_email, to_email = "Hello", "no-reply@example.com", "john@example.com"
333336
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.
409412

410413
### Batch Size
411414

412-
If you may want to limit the number of emails sent in a batch (sometimes
415+
If you may want to limit the number of emails sent in a batch (
413416
useful in a low memory environment), use the `BATCH_SIZE` argument to
414-
limit the number of queued emails fetched in one batch.
417+
limit the number of queued emails fetched in one batch. `BATCH_SIZE` defaults to 100.
415418

416419
```python
417420
# Put this in settings.py
418421
POST_OFFICE = {
419422
...
420-
'BATCH_SIZE': 50,
423+
'BATCH_SIZE': 100,
424+
}
425+
```
426+
427+
Version 3.8 introduces a companion setting called `BATCH_DELIVERY_TIMEOUT`. This setting
428+
specifies the maximum time allowed for each batch to be delivered, this is useful to guard against
429+
cases where delivery process never terminates. Defaults to 180.
430+
431+
If you send a large number of emails in a single batch on a slow connection, consider increasing this number.
432+
433+
```python
434+
# Put this in settings.py
435+
POST_OFFICE = {
436+
...
437+
'BATCH_DELIVERY_TIMEOUT': 180,
421438
}
422439
```
423440

@@ -435,6 +452,17 @@ POST_OFFICE = {
435452
}
436453
```
437454

455+
### Lock File Name
456+
The default lock file name is `post_office`, but this can be altered by setting `LOCK_FILE_NAME` in the configuration.
457+
458+
```python
459+
# Put this in settings.py
460+
POST_OFFICE = {
461+
...
462+
'LOCK_FILE_NAME': 'custom_lock_file',
463+
}
464+
```
465+
438466
### Override Recipients
439467

440468
Defaults to `None`. This option is useful if you want to redirect all
@@ -550,7 +578,7 @@ POST_OFFICE = {
550578
}
551579
```
552580

553-
`CONTEXT_FIELD_CLASS` defaults to `jsonfield.JSONField`.
581+
`CONTEXT_FIELD_CLASS` defaults to `django.db.models.JSONField`.
554582

555583
### Logging
556584

@@ -665,7 +693,7 @@ Attachments are not supported with `mail.send_many()`.
665693
To run the test suite:
666694

667695
```python
668-
`which django-admin.py` test post_office --settings=post_office.test_settings --pythonpath=.
696+
`which django-admin` test post_office --settings=post_office.test_settings --pythonpath=.
669697
```
670698

671699
You can run the full test suite for all supported versions of Django and Python with:

post_office/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import django
21
from ast import literal_eval
32
from os.path import dirname, join
43

5-
with open(join(dirname(__file__), 'version.txt'), 'r') as fh:
4+
with open(join(dirname(__file__), 'version.txt')) as fh:
65
VERSION = literal_eval(fh.read())
76

87
from .backends import EmailBackend
9-
10-
if django.VERSION < (3, 2): # pragma: no cover
11-
default_app_config = 'post_office.apps.PostOfficeConfig'

0 commit comments

Comments
 (0)