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
EmailMessage.objects.create_with_objects(
to=["user@example.com"],
subject="Subject",
# if body not provided it derived from html_message
# using html2text library
body="Hi User,...",
html_message="<p>Hi User...",
# the rest is optional
from_email="no-reply@example.com",
cc=["cc@example.com"],
bcc=["bcc@example.com"],
attachments=[
EmailAttachment.objects.create(
filename="doc.pdf",
mimetype="application/pdf",
file=ContentFile(b"...", name="doc.pdf"),
)
],
reply_to=["Example Team <support@example.com>"],
created_by_id=user.pk,
)
# build EmailMultiAlternatives from db
msg = EmailMessage.objects.get(pk=pk).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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jemail-0.1b1.tar.gz.
File metadata
- Download URL: jemail-0.1b1.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d14377fe3060aa9999e00ca3e626480c217b31e4b06f0095d718deca6bf368a7
|
|
| MD5 |
03a2df1e5f4f8bd6e8802fb37d9b68aa
|
|
| BLAKE2b-256 |
c6c9052a6c7bcc041d7385813397423bda7bb27db3b8428ca1683f334b642b8f
|
Provenance
The following attestation bundles were made for jemail-0.1b1.tar.gz:
Publisher:
main.yml on kotify/jemail
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jemail-0.1b1.tar.gz -
Subject digest:
d14377fe3060aa9999e00ca3e626480c217b31e4b06f0095d718deca6bf368a7 - Sigstore transparency entry: 1432400205
- Sigstore integration time:
-
Permalink:
kotify/jemail@1cec79a8c15b924b1fe13b7545ba8876d1bdc482 -
Branch / Tag:
refs/tags/v0.1b1 - Owner: https://github.com/kotify
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@1cec79a8c15b924b1fe13b7545ba8876d1bdc482 -
Trigger Event:
push
-
Statement type:
File details
Details for the file jemail-0.1b1-py3-none-any.whl.
File metadata
- Download URL: jemail-0.1b1-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d0242863d83f2d6ee34a1d9d47e1e4e32eead26ebd67856e483d6bfb86f8f11
|
|
| MD5 |
c32020547fc48ee26cc85390bcac0318
|
|
| BLAKE2b-256 |
fabc8024f5b8dc3043b80ebfed527b0a04f075e422477195e163d1d87587856c
|
Provenance
The following attestation bundles were made for jemail-0.1b1-py3-none-any.whl:
Publisher:
main.yml on kotify/jemail
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jemail-0.1b1-py3-none-any.whl -
Subject digest:
1d0242863d83f2d6ee34a1d9d47e1e4e32eead26ebd67856e483d6bfb86f8f11 - Sigstore transparency entry: 1432400268
- Sigstore integration time:
-
Permalink:
kotify/jemail@1cec79a8c15b924b1fe13b7545ba8876d1bdc482 -
Branch / Tag:
refs/tags/v0.1b1 - Owner: https://github.com/kotify
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yml@1cec79a8c15b924b1fe13b7545ba8876d1bdc482 -
Trigger Event:
push
-
Statement type: