mail-editor


Namemail-editor JSON
Version 0.3.8 PyPI version JSON
download
home_pageNone
SummaryA Django package for email template editing
upload_time2025-07-30 08:35:01
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseCopyright (c) Maykin Media and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of Django nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords todo
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            MailEditor
==========

.. image:: https://codecov.io/gh/maykinmedia/mail-editor/branch/develop/graph/badge.svg
    :target: https://codecov.io/gh/maykinmedia/mail-editor
    :alt: Coverage
.. image:: https://codeclimate.com/github/codeclimate/codeclimate/badges/gpa.svg
   :target: https://codeclimate.com/github/codeclimate/codeclimate
   :alt: Code Climate


Django e-mail templates!

Many projects have a well defined set of events that trigger an outgoing e-mail,
and the sensible thing is to template these out.

However, doing code updates and deployments for small template tweaks are a bit
cumbersome and annoying.

This project aims to solve that - define the types of templates in the code,
and edit the actual templates in the front-end. Templates are validated on
syntax *and* required/optional content.

This project also aims to solve the HTML email template problems that you can have when
supporting all email clients. This was also used by
`foundation for email`_. Foundation for email is a good way to build your initial email
template on development mode. It will generate a separate html file and css file.

For e-mail sending and logging, we recommend using a solution such as `Django Yubin`_.

This is only tested on a postgres database.

Supported are:

- python 3.10, 3.11, 3.12
- Django 3.2, 4.2
- PostgreSQL

Warning
-------

This project is currently in development and not stable.


Installation
------------

Install with pip:

.. code:: shell

    pip install mail_editor

Add *'mail_editor'* to the installed apps:

.. code:: python

    # settings.py

    INSTALLED_APPS = [
        ...
        'mail_editor',
        'ckeditor',
        ...
    ]

Add the urls:

.. code:: python

    # urls.py

    url(r'^mail-editor/', include('mail_editor.urls', namespace='mail_editor')),


Using the template
--------------------

There are 2 templates that you can use.

The *_base.html*, this template can not be edited by the user. This will only be
rendered when the email is send.

The *_outer_table.html*, this template can be edited by the user and will be loaded
in the editor in the admin. This template will be saved in the database with the
modifications.

You can use the templates in some different ways. The shortest way is:

.. code:: python

    from mail_editor.helpers import find_template

    def email_stuff():
        template = find_template('activation')

        context = {
            'name': 'Test Person',
            'site_name': 'This site',
            'activation_link': 'https://github.com/maykinmedia/mail-editor',
        }

        template.send_email('test@example.com', context)

Settings
--------

The following settings are an example:

.. code:: python

    MAIL_EDITOR_CONF = {
        'activation': {
            'name': gettext_noop('Activation Email'),
            'description': gettext_noop('This email is used when people need to activate their account.'),
            'subject_default': 'Activeer uw account voor {{site_name}}',
            'body_default': """
                <h1>Hallo {{ name }},</h1>

                <p>Welkom! Je hebt je geregistreerd voor een {{ site_name }} account.</p>

                <p>{{ activation_link }}</p>
            """,
            'subject': [{
                'name': 'site_name',
                'description': gettext_noop('This is the name of the site. From the sites'),
                'example': gettext_noop('Example site'),
            }],
            'body': [{
                'name': 'name',
                'description': gettext_noop('This is the name of the user'),
                'example': gettext_noop('Jane Doe'),
            }, {
                'name': 'site_name',
                'description': gettext_noop('This is the name of the site. From the sites'),
                'example': gettext_noop('Example site'),
            }, {
                'name': 'activation_link',
                'description': gettext_noop('This is the link to activate their account.'),
                'example': gettext_noop('/'),
            }]
        },
        ...
    }

These settings are usefull to add:

.. code:: python

    # These settings make sure that CKEDITOR does not strip any html tags. like <center></center>
    CKEDITOR_CONFIGS = {
        'mail_editor': {
            'allowedContent': True,
            'contentsCss': ['/static/css/email.css'], # Enter the css file used to style the email.
            'height': 600,  # This is optional
            'entities': False, # This is added because CKEDITOR escapes the ' when you do an if statement
        }
    }

You can set template variables to all of the mail templates in the following fashion.

.. code:: python

    # static dictionary
    MAIL_EDITOR_BASE_CONTEXT = {
        'url': 'http://www.maykinmedia.nl',
    }

    # import path to callable that returns a dictionary
    MAIL_EDITOR_DYNAMIC_CONTEXT = "dotted.path.to.callable"


Installation
------------

Install with pip:

.. code:: shell

    pip install mail_editor


Local development
-----------------

To install and develop the library locally, use::

.. code-block:: bash

    pip install -e .[tests,coverage,release]

When running management commands via ``django-admin``, make sure to add the root
directory to the python path (or use ``python -m django <command>``):

.. code-block:: bash

    export PYTHONPATH=. DJANGO_SETTINGS_MODULE=testapp.settings
    django-admin check
    # or other commands like:
    django-admin migrate
    django-admin createsuperuser
    django-admin runserver
    # django-admin makemessages -l nl


.. _Django Yubin: https://github.com/APSL/django-yubin
.. _Sergei Maertens: https://github.com/sergei-maertens
.. _langerak-gkv: https://github.com/sergei-maertens/langerak-gkv/blob/master/src/langerak_gkv/mailing/mail_template.py
.. _foundation for email: http://foundation.zurb.com/emails.html
.. role:: python(code)
    :language: python

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mail-editor",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "TODO",
    "author": null,
    "author_email": "Maykin Media <support@maykinmedia.nl>",
    "download_url": "https://files.pythonhosted.org/packages/71/cd/898c5894985207366bc44ab6a390f07fa7b8524bb02aef22fe746678cc6c/mail_editor-0.3.8.tar.gz",
    "platform": null,
    "description": "MailEditor\n==========\n\n.. image:: https://codecov.io/gh/maykinmedia/mail-editor/branch/develop/graph/badge.svg\n    :target: https://codecov.io/gh/maykinmedia/mail-editor\n    :alt: Coverage\n.. image:: https://codeclimate.com/github/codeclimate/codeclimate/badges/gpa.svg\n   :target: https://codeclimate.com/github/codeclimate/codeclimate\n   :alt: Code Climate\n\n\nDjango e-mail templates!\n\nMany projects have a well defined set of events that trigger an outgoing e-mail,\nand the sensible thing is to template these out.\n\nHowever, doing code updates and deployments for small template tweaks are a bit\ncumbersome and annoying.\n\nThis project aims to solve that - define the types of templates in the code,\nand edit the actual templates in the front-end. Templates are validated on\nsyntax *and* required/optional content.\n\nThis project also aims to solve the HTML email template problems that you can have when\nsupporting all email clients. This was also used by\n`foundation for email`_. Foundation for email is a good way to build your initial email\ntemplate on development mode. It will generate a separate html file and css file.\n\nFor e-mail sending and logging, we recommend using a solution such as `Django Yubin`_.\n\nThis is only tested on a postgres database.\n\nSupported are:\n\n- python 3.10, 3.11, 3.12\n- Django 3.2, 4.2\n- PostgreSQL\n\nWarning\n-------\n\nThis project is currently in development and not stable.\n\n\nInstallation\n------------\n\nInstall with pip:\n\n.. code:: shell\n\n    pip install mail_editor\n\nAdd *'mail_editor'* to the installed apps:\n\n.. code:: python\n\n    # settings.py\n\n    INSTALLED_APPS = [\n        ...\n        'mail_editor',\n        'ckeditor',\n        ...\n    ]\n\nAdd the urls:\n\n.. code:: python\n\n    # urls.py\n\n    url(r'^mail-editor/', include('mail_editor.urls', namespace='mail_editor')),\n\n\nUsing the template\n--------------------\n\nThere are 2 templates that you can use.\n\nThe *_base.html*, this template can not be edited by the user. This will only be\nrendered when the email is send.\n\nThe *_outer_table.html*, this template can be edited by the user and will be loaded\nin the editor in the admin. This template will be saved in the database with the\nmodifications.\n\nYou can use the templates in some different ways. The shortest way is:\n\n.. code:: python\n\n    from mail_editor.helpers import find_template\n\n    def email_stuff():\n        template = find_template('activation')\n\n        context = {\n            'name': 'Test Person',\n            'site_name': 'This site',\n            'activation_link': 'https://github.com/maykinmedia/mail-editor',\n        }\n\n        template.send_email('test@example.com', context)\n\nSettings\n--------\n\nThe following settings are an example:\n\n.. code:: python\n\n    MAIL_EDITOR_CONF = {\n        'activation': {\n            'name': gettext_noop('Activation Email'),\n            'description': gettext_noop('This email is used when people need to activate their account.'),\n            'subject_default': 'Activeer uw account voor {{site_name}}',\n            'body_default': \"\"\"\n                <h1>Hallo {{ name }},</h1>\n\n                <p>Welkom! Je hebt je geregistreerd voor een {{ site_name }} account.</p>\n\n                <p>{{ activation_link }}</p>\n            \"\"\",\n            'subject': [{\n                'name': 'site_name',\n                'description': gettext_noop('This is the name of the site. From the sites'),\n                'example': gettext_noop('Example site'),\n            }],\n            'body': [{\n                'name': 'name',\n                'description': gettext_noop('This is the name of the user'),\n                'example': gettext_noop('Jane Doe'),\n            }, {\n                'name': 'site_name',\n                'description': gettext_noop('This is the name of the site. From the sites'),\n                'example': gettext_noop('Example site'),\n            }, {\n                'name': 'activation_link',\n                'description': gettext_noop('This is the link to activate their account.'),\n                'example': gettext_noop('/'),\n            }]\n        },\n        ...\n    }\n\nThese settings are usefull to add:\n\n.. code:: python\n\n    # These settings make sure that CKEDITOR does not strip any html tags. like <center></center>\n    CKEDITOR_CONFIGS = {\n        'mail_editor': {\n            'allowedContent': True,\n            'contentsCss': ['/static/css/email.css'], # Enter the css file used to style the email.\n            'height': 600,  # This is optional\n            'entities': False, # This is added because CKEDITOR escapes the ' when you do an if statement\n        }\n    }\n\nYou can set template variables to all of the mail templates in the following fashion.\n\n.. code:: python\n\n    # static dictionary\n    MAIL_EDITOR_BASE_CONTEXT = {\n        'url': 'http://www.maykinmedia.nl',\n    }\n\n    # import path to callable that returns a dictionary\n    MAIL_EDITOR_DYNAMIC_CONTEXT = \"dotted.path.to.callable\"\n\n\nInstallation\n------------\n\nInstall with pip:\n\n.. code:: shell\n\n    pip install mail_editor\n\n\nLocal development\n-----------------\n\nTo install and develop the library locally, use::\n\n.. code-block:: bash\n\n    pip install -e .[tests,coverage,release]\n\nWhen running management commands via ``django-admin``, make sure to add the root\ndirectory to the python path (or use ``python -m django <command>``):\n\n.. code-block:: bash\n\n    export PYTHONPATH=. DJANGO_SETTINGS_MODULE=testapp.settings\n    django-admin check\n    # or other commands like:\n    django-admin migrate\n    django-admin createsuperuser\n    django-admin runserver\n    # django-admin makemessages -l nl\n\n\n.. _Django Yubin: https://github.com/APSL/django-yubin\n.. _Sergei Maertens: https://github.com/sergei-maertens\n.. _langerak-gkv: https://github.com/sergei-maertens/langerak-gkv/blob/master/src/langerak_gkv/mailing/mail_template.py\n.. _foundation for email: http://foundation.zurb.com/emails.html\n.. role:: python(code)\n    :language: python\n",
    "bugtrack_url": null,
    "license": "Copyright (c) Maykin Media and individual contributors.\n        All rights reserved.\n        \n        Redistribution and use in source and binary forms, with or without\n        modification,\n        are permitted provided that the following conditions are met:\n        \n             1. Redistributions of source code must retain the above copyright\n        notice,\n                this list of conditions and the following disclaimer.\n        \n             2. Redistributions in binary form must reproduce the above copyright\n                notice, this list of conditions and the following disclaimer in the\n                documentation and/or other materials provided with the distribution.\n        \n             3. Neither the name of Django nor the names of its contributors may\n        be used\n                to endorse or promote products derived from this software without\n                specific prior written permission.\n        \n        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS\n        IS\" AND\n        ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n        IMPLIED\n        WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n        LIABLE FOR\n        ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n        DAMAGES\n        (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n        LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\n        AND ON\n        ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n        (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n        THIS\n        SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n        ",
    "summary": "A Django package for email template editing",
    "version": "0.3.8",
    "project_urls": {
        "Bug Tracker": "https://github.com/maykinmedia/mail-editor/issues",
        "Documentation": "https://github.com/maykinmedia/mail-editor",
        "Homepage": "https://github.com/maykinmedia/mail-editor",
        "Source Code": "https://github.com/maykinmedia/mail-editor"
    },
    "split_keywords": [
        "todo"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7168188ec5965ccfa7dd106215c965023e287d2a5e879b38c1683cf38aa3b61e",
                "md5": "52dd9e053c1af418a10b4119772eb072",
                "sha256": "72cfb14a6d483551676638be2fbd1ce6ef78f895a46ce526bbf60ec03d2bfc2e"
            },
            "downloads": -1,
            "filename": "mail_editor-0.3.8-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "52dd9e053c1af418a10b4119772eb072",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.10",
            "size": 30764,
            "upload_time": "2025-07-30T08:35:00",
            "upload_time_iso_8601": "2025-07-30T08:35:00.198113Z",
            "url": "https://files.pythonhosted.org/packages/71/68/188ec5965ccfa7dd106215c965023e287d2a5e879b38c1683cf38aa3b61e/mail_editor-0.3.8-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "71cd898c5894985207366bc44ab6a390f07fa7b8524bb02aef22fe746678cc6c",
                "md5": "e26f0e9f9c144ebeb89013693eb933dd",
                "sha256": "490eb2916a487e9a2caee88a0a427371097e46761ed29e0a357482ad449c8bfb"
            },
            "downloads": -1,
            "filename": "mail_editor-0.3.8.tar.gz",
            "has_sig": false,
            "md5_digest": "e26f0e9f9c144ebeb89013693eb933dd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 107423,
            "upload_time": "2025-07-30T08:35:01",
            "upload_time_iso_8601": "2025-07-30T08:35:01.231676Z",
            "url": "https://files.pythonhosted.org/packages/71/cd/898c5894985207366bc44ab6a390f07fa7b8524bb02aef22fe746678cc6c/mail_editor-0.3.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-30 08:35:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "maykinmedia",
    "github_project": "mail-editor",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "mail-editor"
}
        
Elapsed time: 1.97039s