Skip to main content

Custom extandable mailer for CKAN

Project description

Tests

ckanext-mailcraft

The ckanext-mailcraft adds powerful email management features to CKAN, making it easier to style, track, and control outgoing messages.

Features

  • Flexible Mailer – a custom mailer that can be easily extended to fit your needs
  • Pre-styled Templates – an example email template you can customize to match your branding
  • Email Logging – configurable option to save outgoing emails and view them in the dashboard
  • Email Control – configurable option to temporarily stop outgoing messages when needed
  • Redirection – configurable option to reroute all outgoing emails to one or more specified addresses

To enable the extension, add mailcraft to the ckan.plugins setting in your CKAN. If you want to enable the dashboard you should also add tables mailcraft_dashboard to the ckan.plugins setting.

Usage

To use a mailer, you just have to import it and initialize the mailer.

from ckanext.mailcraft.utils import get_mailer

mailer = get_mailer()

mailer.mail_recipients(
    subject="Hello world",
    recipients=["test@gmail.com"],
    body="Hello world",
    body_html=tk.render(
        "mailcraft/emails/test.html",
        extra_vars={"site_url": mailer.site_url, "site_title": mailer.site_title},
    ),
)

[!IMPORTANT] If you're using environment variables to configure the SMTP server, you must create the mailer instance within a method or function scope; otherwise, the mailer will take the config options from the CKAN config file.

Dashboard


To access the dashboard, first ensure that the tables mailcraft_dashboard plugins are enabled in your CKAN configuration. Then you'll have a button at the top right of the CKAN interface that will take you to the Mailcraft dashboard.

The tables plugin is required to render the dashboard table.

dashboard button

The dashboard provides an overview of all outgoing emails, including their status (sent, failed, etc.), recipients, and timestamps. You can filter and search through the emails to find specific ones.

dashboard

The ckanext.mailcraft.save_emails config option must be set to true to save outgoing emails and view them in the dashboard. You can also press the View button to see the full content of each email.

mail body

Requirements

Compatibility with core CKAN versions:

CKAN version Compatible?
2.9 and earlier no
2.10+ yes

Installation

Use PyPI to install the extension with pip. Or check the Developer installation section.

pip install ckanext-mailcraft

Config settings

Check the config_declaration.yaml file to see all available config settings.

Developer installation

To install ckanext-mailcraft for development, activate your CKAN virtualenv and do:

git clone https://github.com/DataShades/ckanext-mailcraft.git
cd ckanext-mailcraft
python setup.py develop
pip install -r dev-requirements.txt

Build CSS

Run this command from the theme folder.

npx sass styles.scss:./../assets/css/style.css -s compressed --no-source-map

Tests

To run the tests, do:

pytest --ckan-ini=test.ini

License

AGPL

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ckanext_mailcraft-0.9.3.tar.gz (57.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ckanext_mailcraft-0.9.3-py3-none-any.whl (50.0 kB view details)

Uploaded Python 3

File details

Details for the file ckanext_mailcraft-0.9.3.tar.gz.

File metadata

  • Download URL: ckanext_mailcraft-0.9.3.tar.gz
  • Upload date:
  • Size: 57.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for ckanext_mailcraft-0.9.3.tar.gz
Algorithm Hash digest
SHA256 ab4a34780cae6439a5c926c2329f3ab8ae6e4641c2e54d1c90c3c0971dd19652
MD5 99f12628f79ff4cb67cefaeb7717d99f
BLAKE2b-256 5183e79ebbaa76a91b2fbd7e85808f471df7bc36455f8ca4b49f06199a8feb62

See more details on using hashes here.

File details

Details for the file ckanext_mailcraft-0.9.3-py3-none-any.whl.

File metadata

File hashes

Hashes for ckanext_mailcraft-0.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 00c1d456b75d99934cf2e66faa66912a6bc49656cb5c0cbf31260309b9ac8354
MD5 02f40b2cdfe1de4d48b1af91712d53e4
BLAKE2b-256 9f6f3ccb2e7fc885f2d2267a2b61b9b048dd13efb215c456dafaf0ee8be0c93c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page