adhocracy_core.messaging package

Send messages to Principals.

class Messenger(registry: pyramid.registry.Registry)[source]

Bases: object

Send messages to other people.

Create a new instance.

Parameters:registry – used to retrieve and configure the mailer
send_mail(subject: str, recipients: collections.abc.Sequence, sender: str=None, body: str=None, html: str=None, request: pyramid.request.Request=None)[source]

Send a mail message to a list of recipients.

Parameters:
  • subject (str) – the subject of the message
  • recipients (Sequence) – non-empty list of the email addresses of recipients
  • sender (str) – the email message of the sender; if None, the configured default sender address will be used
  • body (str) – the plain text body of the message, may be omitted but only if html is given
  • html (str) – body: the HTML body of the message, may be omitted but only if body is given
  • request (Request) – the current request object, if None pyramid.threadlocal.get_current_request is used
Raises:
  • ValueError – if recipients is empty or if both body and html are missing or empty
  • ConnectionError – if no connection to the configured mail server can be established
  • smtplib.SMTPException – if the mail cannot be sent because the target mail server doesn’t exist or rejects the connection
send_abuse_complaint(url: str, remark: str, user: <InterfaceClass adhocracy_core.interfaces.IResource>=None, request: pyramid.request.Request=None)[source]

Send an abuse complaint to the preconfigured abuse handler.

Parameters:
  • url (str) – the frontend URL of the resource considered offensive
  • remark (str) – explanation provided by the complaining user
  • user – the complaining user, or None if not logged in
send_message_to_user(recipient: <InterfaceClass adhocracy_core.interfaces.IResource>, title: str, text: str, from_user: <InterfaceClass adhocracy_core.interfaces.IResource>, request: pyramid.request.Request=None)[source]

Send a message to a specific user.

send_registration_mail(user: <InterfaceClass adhocracy_core.resources.principal.IUser>, activation_path: str, request: pyramid.request.Request=None)[source]

Send a registration mail to validate the email of a user account.

send_password_reset_mail(user=<InterfaceClass adhocracy_core.resources.principal.IUser>, password_reset=<InterfaceClass adhocracy_core.interfaces.IResource>, request: pyramid.request.Request=None)[source]

Send email with link to reset the user password.

send_invitation_mail(user=<InterfaceClass adhocracy_core.resources.principal.IUser>, password_reset=<InterfaceClass adhocracy_core.interfaces.IResource>, request: pyramid.request.Request=None, subject_tmpl: str=None, body_tmpl: str=None)[source]

Send invitation email with link to reset the user password.

Parameters:
  • subject_tmpl (str) – pyramid asset pointing to a mako template file. If not set the translation message is used for the mail subject.
  • body_tmpl (str) – pyramid asset pointing to a mako template file. If not set the translation message is used for the mail body.
send_activity_mail(user: <InterfaceClass adhocracy_core.resources.principal.IUser>, activity: adhocracy_core.interfaces.Activity, request: pyramid.request.Request)[source]

Send email describing an activity event.

The following variables are provided for translations strings:

  • site_name
  • object_url
  • target_url
  • activity_name
  • activity_description
  • object_type_name
  • target_type_name
send_password_change_mail(user=<InterfaceClass adhocracy_core.resources.principal.IUser>, request: pyramid.request.Request=None)[source]

Send email with link to reset the user password.

send_new_email_activation_mail(user: <InterfaceClass adhocracy_core.resources.principal.IUser>, activation_path: str, new_email: str, request: pyramid.request.Request=None)[source]

Send a activation mail to validate the new email of a user.

includeme(config)[source]

Add Messenger to registry.