django-appmail


Namedjango-appmail JSON
Version 6.0 PyPI version JSON
download
home_pagehttps://github.com/yunojuno/django-appmail
SummaryDjango app for managing localised email templates.
upload_time2023-11-14 14:41:34
maintainer
docs_urlNone
authorYunoJuno
requires_python>=3.9,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # Django-AppMail

[![PyPI](https://img.shields.io/pypi/v/django-appmail.svg)](https://pypi.org/project/django-appmail/)

Django app for managing transactional email templates.

## Compatibility

This project now requires Django 4.0+ and Python 3.9+. If you require a previous
version you will have to refer to the relevant branch or tag.

## Background

This project arose out of a project to integrate a large transactional Django
application with Mandrill, and the lessons learned. It also owes a minor h/t to
this project from 2011 (https://github.com/hugorodgerbrown/AppMail).

The core requirement is to provide an easy way to add / edit email templates to
a Django project, in such a way that it doesn't require a developer to make
changes. The easiest way to use templated emails in Django is to rely on the
in-built template structure, but that means that the templates are held in
files, under version control, which makes it very hard for non-developers to
edit.

This is **not** a WYSIWYG HTML editor, and it doesn't do anything clever. It
doesn't handle the sending of the emails - it simply provides a convenient
mechanism for storing and rendering email content.

```python
from appmail.models import EmailTemplate, AppmailMessage

def send_order_confirmation(order_id):
    order = Orders.objects.get(id=order_id)
    template = EmailTemplate.objects.current('order_confirmation')
    context = { "order": order }
    message = AppmailMessage(
        template=template,
        context=context,
        to=[order.recipient.email]
    )
    message.send()
```

The core requirements are:

1. List / preview existing templates
2. Edit subject line, plain text and HTML content
3. Use standard Django template syntax
4. Support base templates
5. Template versioning
6. Language support
7. Send test emails
8. Log emails sent (if desired)

### Email logging (v2)

From v2 on, it is possible to log all emails that are sent via
`AppmailMessage.send`. It records the template, context and the rendered output,
so that the email can be views as sent, and resent. It will attempt to record
the User to whom the email was sent, as well as the email address. This is
dependent on there being a unique 1:1 match from email to User object, but can
prove useful in tracking emails sent to users when they change their email
address.

### Template properties

Individual templates are stored as model objects in the database. The standard
Django admin site is used to view / filter templates. The templates are ordered
by name, language and version. This combination is unique. The language and
version properties have sensible defaults (`version=settings.LANGUAGE_CODE` and
`version=0`) so don't need to set if you don't require it. There is no
inheritance or relationship between different languages and versions - they are
stored as independent objects.

```python
# get the default order_summary email (language = settings.LANGUAGE_CODE)
template = EmailTemplate.objects.current('order_summary')
# get the french version
template = EmailTemplate.objects.current('order_summary', language='fr')
# get a specific version
template = EmailTemplate.objects.version('order_summary', 1)
```

**Template syntax**

The templates themselves use standard Django template syntax, including the use
of tags, filters. There is nothing special about them, however there is one
caveat - template inheritance.

**Template inheritance**

Although the template content is not stored on disk, without re-engineering the
template rendering methods any parent templates must be. This is annoying, but
there is a valid assumption behind it - if you are changing your base templates
you are probably involving designers and developers already, so having to rely
on a developer to make the changes is acceptable.

**Sending test emails**

You can send test emails to an email address through the admin list view.

<img src="screenshots/appmail-test-email-action.png" alt="EmailTemplate admin
change form" />

The custom admin action 'Send test emails' will redirect to an intermediate page
where you can enter the recipient email address and send the email:

<img src="screenshots/appmail-test-email-send.png"/>

There is also a linkon individual template admin pages (top-right, next to the
history link):

<img src="screenshots/appmail-template-change-form.png" alt="EmailTemplate admin
change form" />

## Tests

There is a test suite for the app, which is best run through `tox`.

## License

MIT

## Contributing

Usual rules apply:

1. Fork to your own account
2. Fix the issue / add the feature
3. Submit PR

Please take care to follow the coding style - and PEP8.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/yunojuno/django-appmail",
    "name": "django-appmail",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "YunoJuno",
    "author_email": "code@yunojuno.com",
    "download_url": "https://files.pythonhosted.org/packages/33/66/943ba588808973de0f0ba323663eb51d3abf526d049c680ad86583bc4bad/django_appmail-6.0.tar.gz",
    "platform": null,
    "description": "# Django-AppMail\n\n[![PyPI](https://img.shields.io/pypi/v/django-appmail.svg)](https://pypi.org/project/django-appmail/)\n\nDjango app for managing transactional email templates.\n\n## Compatibility\n\nThis project now requires Django 4.0+ and Python 3.9+. If you require a previous\nversion you will have to refer to the relevant branch or tag.\n\n## Background\n\nThis project arose out of a project to integrate a large transactional Django\napplication with Mandrill, and the lessons learned. It also owes a minor h/t to\nthis project from 2011 (https://github.com/hugorodgerbrown/AppMail).\n\nThe core requirement is to provide an easy way to add / edit email templates to\na Django project, in such a way that it doesn't require a developer to make\nchanges. The easiest way to use templated emails in Django is to rely on the\nin-built template structure, but that means that the templates are held in\nfiles, under version control, which makes it very hard for non-developers to\nedit.\n\nThis is **not** a WYSIWYG HTML editor, and it doesn't do anything clever. It\ndoesn't handle the sending of the emails - it simply provides a convenient\nmechanism for storing and rendering email content.\n\n```python\nfrom appmail.models import EmailTemplate, AppmailMessage\n\ndef send_order_confirmation(order_id):\n    order = Orders.objects.get(id=order_id)\n    template = EmailTemplate.objects.current('order_confirmation')\n    context = { \"order\": order }\n    message = AppmailMessage(\n        template=template,\n        context=context,\n        to=[order.recipient.email]\n    )\n    message.send()\n```\n\nThe core requirements are:\n\n1. List / preview existing templates\n2. Edit subject line, plain text and HTML content\n3. Use standard Django template syntax\n4. Support base templates\n5. Template versioning\n6. Language support\n7. Send test emails\n8. Log emails sent (if desired)\n\n### Email logging (v2)\n\nFrom v2 on, it is possible to log all emails that are sent via\n`AppmailMessage.send`. It records the template, context and the rendered output,\nso that the email can be views as sent, and resent. It will attempt to record\nthe User to whom the email was sent, as well as the email address. This is\ndependent on there being a unique 1:1 match from email to User object, but can\nprove useful in tracking emails sent to users when they change their email\naddress.\n\n### Template properties\n\nIndividual templates are stored as model objects in the database. The standard\nDjango admin site is used to view / filter templates. The templates are ordered\nby name, language and version. This combination is unique. The language and\nversion properties have sensible defaults (`version=settings.LANGUAGE_CODE` and\n`version=0`) so don't need to set if you don't require it. There is no\ninheritance or relationship between different languages and versions - they are\nstored as independent objects.\n\n```python\n# get the default order_summary email (language = settings.LANGUAGE_CODE)\ntemplate = EmailTemplate.objects.current('order_summary')\n# get the french version\ntemplate = EmailTemplate.objects.current('order_summary', language='fr')\n# get a specific version\ntemplate = EmailTemplate.objects.version('order_summary', 1)\n```\n\n**Template syntax**\n\nThe templates themselves use standard Django template syntax, including the use\nof tags, filters. There is nothing special about them, however there is one\ncaveat - template inheritance.\n\n**Template inheritance**\n\nAlthough the template content is not stored on disk, without re-engineering the\ntemplate rendering methods any parent templates must be. This is annoying, but\nthere is a valid assumption behind it - if you are changing your base templates\nyou are probably involving designers and developers already, so having to rely\non a developer to make the changes is acceptable.\n\n**Sending test emails**\n\nYou can send test emails to an email address through the admin list view.\n\n<img src=\"screenshots/appmail-test-email-action.png\" alt=\"EmailTemplate admin\nchange form\" />\n\nThe custom admin action 'Send test emails' will redirect to an intermediate page\nwhere you can enter the recipient email address and send the email:\n\n<img src=\"screenshots/appmail-test-email-send.png\"/>\n\nThere is also a linkon individual template admin pages (top-right, next to the\nhistory link):\n\n<img src=\"screenshots/appmail-template-change-form.png\" alt=\"EmailTemplate admin\nchange form\" />\n\n## Tests\n\nThere is a test suite for the app, which is best run through `tox`.\n\n## License\n\nMIT\n\n## Contributing\n\nUsual rules apply:\n\n1. Fork to your own account\n2. Fix the issue / add the feature\n3. Submit PR\n\nPlease take care to follow the coding style - and PEP8.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Django app for managing localised email templates.",
    "version": "6.0",
    "project_urls": {
        "Homepage": "https://github.com/yunojuno/django-appmail",
        "Repository": "https://github.com/yunojuno/django-appmail"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e35099efb50d13d0493b266e87a1f303ef25cf3f7aa7d7e89fc6f748fc854045",
                "md5": "630ece64ac44ad357a489b04f3977ec9",
                "sha256": "2aedb39e0335329945e799886962fb9952617d72b088ea4433dc8f8cc11c8dea"
            },
            "downloads": -1,
            "filename": "django_appmail-6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "630ece64ac44ad357a489b04f3977ec9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 28543,
            "upload_time": "2023-11-14T14:41:32",
            "upload_time_iso_8601": "2023-11-14T14:41:32.867534Z",
            "url": "https://files.pythonhosted.org/packages/e3/50/99efb50d13d0493b266e87a1f303ef25cf3f7aa7d7e89fc6f748fc854045/django_appmail-6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3366943ba588808973de0f0ba323663eb51d3abf526d049c680ad86583bc4bad",
                "md5": "934b43cba8213f2a2a87634f97a22c7e",
                "sha256": "59d24e3a58f9875b361066c61e0b61f2c53b09e3b7bdeb628004319d01d4ff78"
            },
            "downloads": -1,
            "filename": "django_appmail-6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "934b43cba8213f2a2a87634f97a22c7e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 21507,
            "upload_time": "2023-11-14T14:41:34",
            "upload_time_iso_8601": "2023-11-14T14:41:34.863731Z",
            "url": "https://files.pythonhosted.org/packages/33/66/943ba588808973de0f0ba323663eb51d3abf526d049c680ad86583bc4bad/django_appmail-6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-14 14:41:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yunojuno",
    "github_project": "django-appmail",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "django-appmail"
}
        
Elapsed time: 0.13531s