Name | jemail JSON |
Version |
0.1a4
JSON |
| download |
home_page | None |
Summary | Django app to store emails in db |
upload_time | 2024-07-17 10:28:27 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
django
email
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Jemail
Django app to store emails in db
## Installation
```sh
pip install jemail
pip install django-anymail[sendgrid]
```
Anymail used as email backend, for now jemail tested only with `sendgrid` backend.
Update settings with:
```python
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
```python
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:
```sh
echo "use flake" >> .envrc
direnv allow
app.install
pytest
```
nix:
```sh
nix develop
app.install
pytest
```
uv:
```sh
uv -q venv .venv
source .venv/bin/activate
uv pip install -e .[dev,test]
pre-commit install
pytest
```
Raw data
{
"_id": null,
"home_page": null,
"name": "jemail",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "django, email",
"author": null,
"author_email": "Konstantin Alekseev <mail@kalekseev.com>",
"download_url": "https://files.pythonhosted.org/packages/19/df/b53fc8710ae64b21911d182f1c56cd757baefeff35cacc641b3528bfce82/jemail-0.1a4.tar.gz",
"platform": null,
"description": "# Jemail\n\nDjango app to store emails in db\n\n\n## Installation\n\n```sh\npip install jemail\npip install django-anymail[sendgrid]\n```\n\nAnymail used as email backend, for now jemail tested only with `sendgrid` backend.\n\nUpdate settings with:\n\n```python\nEMAIL_BACKEND = \"anymail.backends.sendgrid.EmailBackend\"\n\n# defaults\nJEMAIL = {\n \"METADATA_ID_KEY\": \"message_id\", # tag name for EmailMessage.pk in message metadata\n \"HTML_MESSAGE_UPLOAD_TO\": \"emails/messages/\", # path to save html messages to\n \"ATTACHMENT_UPLOAD_TO\": \"emails/attachments/\", # path to save attachments to\n # \"IMPORT_HTML_MESSAGE_UPLOAD_TO\": \"myproject.utils.message_upload_to\", # callable option\n # \"IMPORT_ATTACHMENT_UPLOAD_TO\": \"myproject.utils.attachment_upload_to\", # callable option\n}\n```\n\n## Usage\n\n```python\nfrom jemail import EmailMessage, EmailAttachment\n\n# save email in db\nEmailMessage.objects.create_with_objects(\n to=[\"user@example.com\"],\n subject=\"Subject\",\n # if body not provided it derived from html_message\n # using html2text library\n body=\"Hi User,...\",\n html_message=\"<p>Hi User...\",\n # the rest is optional\n from_email=\"no-reply@example.com\",\n cc=[\"cc@example.com\"],\n bcc=[\"bcc@example.com\"],\n attachments=[\n EmailAttachment.objects.create(\n filename=\"doc.pdf\",\n mimetype=\"application/pdf\",\n file=ContentFile(b\"...\", name=\"doc.pdf\"),\n )\n ],\n reply_to=[\"Example Team <support@example.com>\"],\n created_by_id=user.pk,\n)\n\n# build EmailMultiAlternatives from db\nmsg = EmailMessage.objects.get(pk=pk).build_message()\n# send email\nmsg.send()\n```\n\n## Development\n\nnix-direnv:\n\n```sh\necho \"use flake\" >> .envrc\ndirenv allow\napp.install\npytest\n```\n\nnix:\n\n```sh\nnix develop\napp.install\npytest\n```\n\nuv:\n\n```sh\nuv -q venv .venv\nsource .venv/bin/activate\nuv pip install -e .[dev,test]\npre-commit install\npytest\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Django app to store emails in db",
"version": "0.1a4",
"project_urls": {
"Changelog": "https://github.com/kotify/jemail/blob/main/CHANGELOG.md",
"Repository": "https://github.com/kotify/jemail"
},
"split_keywords": [
"django",
" email"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ca4e6cfc2cfb156e049e8920430d404e66b91a9b06bb2110cd948a5c4f6ed12c",
"md5": "420f2f88c42f7767984c40f140c52d0f",
"sha256": "2c05ed1d1e67ae0f67332806563ad17b7a490a9f75dfe0fc0ad5d6d4d1908396"
},
"downloads": -1,
"filename": "jemail-0.1a4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "420f2f88c42f7767984c40f140c52d0f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 10128,
"upload_time": "2024-07-17T10:28:25",
"upload_time_iso_8601": "2024-07-17T10:28:25.976626Z",
"url": "https://files.pythonhosted.org/packages/ca/4e/6cfc2cfb156e049e8920430d404e66b91a9b06bb2110cd948a5c4f6ed12c/jemail-0.1a4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "19dfb53fc8710ae64b21911d182f1c56cd757baefeff35cacc641b3528bfce82",
"md5": "7d44e01f36aa39b992b949a55ffbc198",
"sha256": "04445821599a5e42649d4e3385b47c31af9389fdd02e34fa78f2bb8b270cb917"
},
"downloads": -1,
"filename": "jemail-0.1a4.tar.gz",
"has_sig": false,
"md5_digest": "7d44e01f36aa39b992b949a55ffbc198",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 8726,
"upload_time": "2024-07-17T10:28:27",
"upload_time_iso_8601": "2024-07-17T10:28:27.528704Z",
"url": "https://files.pythonhosted.org/packages/19/df/b53fc8710ae64b21911d182f1c56cd757baefeff35cacc641b3528bfce82/jemail-0.1a4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-17 10:28:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kotify",
"github_project": "jemail",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "jemail"
}