Package: kinto-emailer
kinto-emailersend emails when some events arise (e.g. new records have
been created). It relies onPyramid Mailerfor the sending part.Installpip install kinto-emailerSetupIn theKintosettings:kinto.includes=kinto_emailermail.default_sender=kinto@restmail.net# mail.host = localhost# mail.port = 25# mail.username = None# mail.password = None# mail.tls = False# mail.queue_path = NoneIfmail.queue_pathis set, the emails are storage in a local Maildir queue.Seemore details about Pyramid Mailer configuration.Validate configurationThe 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.netDevelopmentUse a fake emailer that write emails files to disk:mail.debug_mailer=trueHow 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.UsageThe 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>")RecipientsThe list of recipients can either contain:Email adresses (eg.alice@wonderland.comor"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).SelectionIt is possible to define severalhooks, 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:recordorcollection(default: all)action:create,update,delete(default: all)collection_id(default: all)record_id(default: all)event:kinto.core.events.AfterResourceChanged(default), orkinto_remote_settings.signer.events.ReviewRequested,kinto_remote_settings.signer.events.ReviewApproved,kinto_remote_settings.signer.events.ReviewRejectedIf 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 specificcollection_id, set the filter value to:^(?!normandy-recipes$).TemplateThe template string can have placeholders:bucket_idid: record or collectioniduser_idresource_nameuriactiontimestamproot_urlclient_addressuser_agentsettings[name]For example:{user_id} has {action}d a {resource_name} in {bucket_id}.SeeKinto core notifications.Running the testsTo run the unit tests:$ make testsFor the functional tests, run a Kinto instance in a separate terminal:$ make run-kintoAnd start the test suite:$ make functionalReleasingCreate a release on Github onhttps://github.com/Kinto/kinto-emailer/releases/newCreate a new tagX.Y.Z(This tag will be created from the target when you publish this release.)Generate release notesPublish release