Django app to store emails in db
Project description
Jemail
Django app to store emails in db
Installation
pip install jemail
pip install django-anymail[sendgrid]
Anymail used as email backend, for now jemail tested only with sendgrid
backend.
Update settings with:
EMAIL_BACKEND = "anymail.backends.sendgrid.EmailBackend"
# defaults
JEMAIL = {
"METADATA_ID_KEY": "message_id", # tag name for EmailMessage.pk in message metadata
"HTML_MESSAGE_UPLOAD_TO": "emails/messages/", # path to save html messages to
"ATTACHMENT_UPLOAD_TO": "emails/attachments/", # path to save attachments to
# "IMPORT_HTML_MESSAGE_UPLOAD_TO": "myproject.utils.message_upload_to", # callable option
# "IMPORT_ATTACHMENT_UPLOAD_TO": "myproject.utils.attachment_upload_to", # callable option
}
Usage
from jemail import EmailMessage, EmailAttachment
# save email in db
message = EmailMessage.objects.create_with_objects(
from_email='no-reply@example.com',
to=['user@example.com'],
subject='Subject',
body='Hi User,...',
html_message='<p>Hi User...',
cc=['cc@example.com'],
reply_to='support@example.com',
attachments=[EmailAttachment.objects.create(
filename='doc.pdf',
mimetype='application/pdf',
file=ContentFile(b'...', name='doc.pdf')
)],
# build EmailMultiAlternatives from db
msg = message.build_message()
# send email
msg.send()
)
Development
nix-direnv:
echo "use flake" >> .envrc
direnv allow
app.install
pytest
nix:
nix develop
app.install
pytest
uv:
uv -q venv .venv
source .venv/bin/activate
uv pip install -e .[dev,test]
pre-commit install
pytest
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
jemail-0.1a1.tar.gz
(8.3 kB
view details)
Built Distribution
File details
Details for the file jemail-0.1a1.tar.gz
.
File metadata
- Download URL: jemail-0.1a1.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec50d751fd4dd8d7517b6c1e638e9c64fa01b7fba12a3d3b4e7832ce1417b73c |
|
MD5 | d33bb460830fa99b22f45acc9f2ae1b7 |
|
BLAKE2b-256 | f6e8251c4d54217aae5de60d3898d68a0e8a71712a58bbc7773a2ea6cf2a3aac |
File details
Details for the file jemail-0.1a1-py3-none-any.whl
.
File metadata
- Download URL: jemail-0.1a1-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 226a80422d895828ccb193a0d25e94bfac0223709cb4a869e4d781b5ce67a8de |
|
MD5 | 891fcf432b18b617b2520a082705dc61 |
|
BLAKE2b-256 | 410c4344e8556420dd38edc8aa523cffc079d335ea9e203b5ae12c2d63ae982c |