Skip to main content
Release file added late

1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.

https://img.shields.io/travis/Kinto/kinto-emailer.svg https://img.shields.io/pypi/v/kinto-emailer.svg https://coveralls.io/repos/Kinto/kinto-emailer/badge.svg?branch=master

kinto-emailer send emails when some events arise (e.g. new records have been created). It relies on Pyramid Mailer for the sending part.

Install

pip install kinto-emailer

Setup

In the Kinto settings:

kinto.includes = kinto_emailer

mail.default_sender = kinto@restmail.net

# mail.host = localhost
# mail.port = 25
# mail.username = None
# mail.password = None
# mail.tls = False
# mail.queue_path = None

If mail.queue_path is set, the emails are storage in a local Maildir queue.

See more details about Pyramid Mailer configuration.

Validate configuration

The following command will send a dummy email to the specified recipient or will fail if the configuration is not correct:

$ kinto-send-email config/kinto.ini testemailer@restmail.net

Development

Use a fake emailer that write emails files to disk:

mail.debug_mailer = true

How does it work?

Some information — like monitored action or list of recipients — are defined in the collection or the bucket metadata. When an event occurs, the plugin sends emails if one of the expected condition is met.

Usage

The metadata on the collection (or the bucket) must look like this:

{
  "kinto-emailer": {
    "hooks": [{
      "template": "Something happened!",
      "recipients": ['Security reviewers <security-reviews@mozilla.com>']
    }]
  }
}

In the above example, every action on the collection metadata or any record in that collection will trigger an email notification.

The metadata of the collection override the bucket metadata, they are not merged.

Optional:

  • subject (e.g. "An action was performed")

  • sender (e.g. "Kinto team <developers@kinto-storage.org>")

Recipients

The list of recipients can either contain:

  • Email adresses (eg. alice@wonderland.com or "Joe Doe <jon@doe.com>")

  • Group URI (eg. /buckets/staging/groups/reviewers)

With group URIs, the email recipients will be expanded with the group members principals look like email addresses (eg. ldap:peace@world.org).

Selection

It is possible to define several hooks, and filter on some condition. For example:

{
  "kinto-emailer": {
    "hooks": [{
      "resource_name": "record",
      "action": "create",
      "template": "Record created!",
      "recipients": ['Security reviewers <security-reviews@mozilla.com>']
    }, {
      "resource_name": "collection",
      "action": "updated",
      "template": "Collection updated!",
      "recipients": ["Security reviewers <security-reviews@mozilla.com>"]
    }]
  }
}

The possible filters are:

  • resource_name: record or collection (default: all)

  • action: create, update, delete (default: all)

  • collection_id (default: all)

  • record_id (default: all)

  • event: kinto.core.events.AfterResourceChanged (default), or kinto_signer.events.ReviewRequested, kinto_signer.events.ReviewApproved, kinto_signer.events.ReviewRejected

If a filter value starts with the special character ^, then the matching will consider the filter value to be a regular expression.

For example, in order to exclude a specific collection_id, set the filter value to: ^(?!normandy-recipes$).

Template

The template string can have placeholders:

  • bucket_id

  • id: record or collection id)

  • user_id

  • resource_name

  • uri

  • action

  • timestamp

  • root_url

  • client_address

  • user_agent

  • settings[name]

For example:

{user_id} has {action}d a {resource_name} in {bucket_id}.

See Kinto core notifications.

Running the tests

To run the unit tests:

$ make tests

For the functional tests, run a Kinto instance in a separate terminal:

$ make run-kinto

And start the test suite:

$ make functional

Changelog

This document describes changes between each past release.

2.1.0 (2021-11-29)

New features

  • Add ability to use settings values in placeholders (#294). For example: "subject": "Email from {settings[project_name]}"

2.0.0 (2020-12-01)

  • Remove template variable validation

1.1.0 (2019-02-20)

New features

  • Allow regexp in filters values when selecting events (#88)

1.0.2 (2018-04-17)

Internal changes

  • Get rid of six

1.0.1 (2017-11-21)

Bug fixes

  • Don’t block on Pyramid 1.8 anymore. (#46)

1.0.0 (2017-06-28)

Bug fixes

  • Fix crash when creating bucket with POST /buckets (fixes #43)

0.4.0 (2017-04-14)

New features

  • Add a validate_setup.py script to check that server can actually send emails

  • Add a kinto-send-email command to test the configuration (fixes #35)

Bug fixes

  • Fix sending notifications by decoupling it from transactions (fixes #38)

0.3.0 (2017-01-30)

New features

  • Support configuration from bucket metadata (fixes #27)

  • Send mail to local Maildir queue if mail.queue_path setting is defined (ref #3)

Bug fixes

  • Fix support of batch requests (fixes #24)

0.2.0 (2017-01-27)

New features

  • List of recipients can now contain groups URIs. The principals from the specified group that look like email addresses will be used as recipients (fixes #6)

  • Support new variables like server root url or client IP address in email template (fixes #22)

  • Add some validation when defining kinto-emailer settings in collections metadata (fixes #21)

0.1.0 (2017-01-25)

Initial version

  • Use a list of hooks to configure emails bound to notifications (fixes #11)

  • Support kinto-signer events (fixes #14)

Contributors

Metadata

Release files for kinto-emailer 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

File added late

1 file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release files before installing.

Source distribution (sdist)

Source distribution for kinto-emailer 2.1.0
File Size Uploaded Provenance Actions
kinto-emailer-2.1.0.tar.gz 16.0 kB Without provenance Details for kinto-emailer-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kinto-emailer 2.1.0
File Interpreter ABI Platform Actions
kinto_emailer-2.1.0-py3-none-any.whl Python 3 none any Details for kinto_emailer-2.1.0-py3-none-any.whl

Total release size: 29.7 kB

Release files / kinto-emailer-2.1.0.tar.gz

Download URL kinto-emailer-2.1.0.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5307f0451625f316143247501941c1916235ca9f9295b9248a29bf81c5ad321b
BLAKE2b-256 checksum
How to use checksums
0a5457eae35b54a9645f66ba2ef885a4adfd91709c4a5d80e7967a84b944d5ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.10

Release files / kinto_emailer-2.1.0-py3-none-any.whl

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL kinto_emailer-2.1.0-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0579e6656dfbf1b928ae9f16012f88b13e97ad7d56831137297b90fc30a6d625
BLAKE2b-256 checksum
How to use checksums
b39e1fc676722b3e1c7f9ec7f7313a9347945ead2d3c5e6679c0d4fe2d7f0321
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Security for kinto-emailer 2.1.0

Upload timing

Release file added late

1 file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.


Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page