Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into database_mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Jul 25, 2024
2 parents ebd654c + a04ba1a commit 2f26f76
Show file tree
Hide file tree
Showing 47 changed files with 1,512 additions and 797 deletions.
13 changes: 13 additions & 0 deletions .github/dependabot.yml
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
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
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 }}
30 changes: 20 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,47 @@ name: Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

permissions:
contents: read

jobs:
jobs:
ruff-format:
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
with:
version: 0.4.8
args: 'format --check'

build:
runs-on: ubuntu-latest
name: Python${{ matrix.python-version }}/Django${{ matrix.django-version }}
strategy:
matrix:
python-version: ["3.9"]
django-version: ["3.2.16", "4.0.8", "4.1.3"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
django-version: ["4.2", "5.0"]
exclude:
- python-version: "3.9"
django-version: "5.0"


steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.2.0
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install django==${{ matrix.django-version }}
pip install jsonfield pytz
pip install "Django~=${{ matrix.django-version }}.0"
- name: Run Test
run: |
`which django-admin` test post_office --settings=post_office.test_settings --pythonpath=.
`which django-admin` test post_office --settings=post_office.test_settings --pythonpath=.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
Changelog
=========

Version 3.9.0 (2024-06-19)
--------------------------
* Added a new `LOCK_FILE_NAME` which lets you change post office's lock file name. Thanks @mogost!
* Fixes a bug where `email_queued` signal is not sent in certain cases. Thanks @diesieben07!
* Fixes an issue where attachment admin page would not render with large number of emails. Thanks @petrprikryl!
* Fixes a crash when email instances are made with context, but without a template. Thanks @pacahon!
* Other miscellaneous fixes and house keeping tasks by @mogost!

Version 3.8.0 (2023-10-22)
--------------------------
* Added `BATCH_DELIVERY_TIMEOUT` that specifies the maximum time allowed for each batch to be delivered. Defaults to 180 seconds. Thanks @selwin!

Version 3.7.1 (2023-08-08)
--------------------------
* Optimized a queryset in `get_queued()` that doesn't use indexes in Postgres. Thanks @marsha97!
* Removed `date_hierarchy` option which causes admin to load slowly on DBs with a large number of emails. Thanks @selwin!
* Optimized `cleanup_expired_mails()` so that deletes emails in smaller batches. Thanks @marsha97!

Version 3.7.0 (2023-05-30)
--------------------------
* Changed JSON columns to use Django's `JSONField` and drop `jsonfield` dependency. Thanks @jrief!
* Fixed saving HTML emails that have `quoted_printable`. Thanks @gabn88!
* Fixes an issue where emails are rendered without context in Django's admin interface. Thanks @zagl!
* This version no longer supports Django 3.1.

Version 3.6.3 (2022-10-27)
--------------------------
* Fixed an issue where emails may not be rendered with context. Thanks @zagl!
Expand Down
48 changes: 38 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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]"
Expand All @@ -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')
Expand Down Expand Up @@ -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,
}
```

Expand All @@ -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
Expand Down Expand Up @@ -550,7 +578,7 @@ POST_OFFICE = {
}
```

`CONTEXT_FIELD_CLASS` defaults to `jsonfield.JSONField`.
`CONTEXT_FIELD_CLASS` defaults to `django.db.models.JSONField`.

### Logging

Expand Down Expand Up @@ -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:
Expand Down
6 changes: 1 addition & 5 deletions post_office/__init__.py
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'
Loading

0 comments on commit 2f26f76

Please sign in to comment.