This release is a pre-release and may not be stable for production use.
Usage
django-mailer is asynchronous so in addition to putting mail on the queue you need to periodically tell it to clear the queue and actually send the mail.
The latter is done via a command extension.
Putting Mail On The Queue
Because django-mailer currently uses the same function signature as Django’s core mail support you can do the following in your code:
# favour django-mailer but fall back to django.core.mail
from django.conf import settings
if "mailer" in settings.INSTALLED_APPS:
from mailer import send_mail
else:
from django.core.mail import send_mail
and then just call send_mail like you normally would in Django:
send_mail(subject, message_body, settings.DEFAULT_FROM_EMAIL, recipients)
Additionally you can send all the admins as specified in the ADMIN setting by calling:
mail_admins(subject, message_body)
or all managers as defined in the MANAGERS setting by calling:
mail_managers(subject, message_body)
Clear Queue With Command Extensions
With mailer in your INSTALLED_APPS, there will be two new manage.py commands you can run:
send_mail will clear the current message queue. If there are any failures, they will be marked deferred and will not be attempted again by send_mail.
retry_deferred will move any deferred mail back into the normal queue (so it will be attempted again on the next send_mail).
You may want to set these up via cron to run regularly:
* * * * * (cd $PINAX; /usr/local/bin/python2.5 manage.py send_mail >> $PINAX/cron_mail.log 2>&1) 0,20,40 * * * * (cd $PINAX; /usr/local/bin/python2.5 manage.py retry_deferred >> $PINAX/cron_mail_deferred.log 2>&1)
This attempts to send mail every minute with a retry on failure every 20 minutes.
manage.py send_mail uses a lock file in case clearing the queue takes longer than the interval between calling manage.py send_mail.
Metadata
Release files for django-mailer 0.1.0alpha
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django-mailer-0.1.0alpha.tar.gz | 9.6 kB | Without provenance | Details |
Release files / django-mailer-0.1.0alpha.tar.gz
| Download URL | django-mailer-0.1.0alpha.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
491bdd76687208f1e2c0254b282dfa3317293710e982813a5c1826456187ae88
|
|
BLAKE2b-256 checksum How to use checksums |
fe6bfeecf93c7fdff08300d5448eb5ad1d87bf4d5eb9f93ec955320899f34513
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-mailer 0.1.0alpha
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.