Jump to >

reviewboard.notifications.email.message

The Review Board e-mail message class and methods for generating e-mails.

HEADER_ADDITIONAL_CHARACTERS_LENGTH = 26[source]

The number of additional characters each X-ReviewBoard-Diff-For has.

We calculate the length the value of each header at runtime. However, X-ReviewBoard-Diff-For: `` is present before the value, and the line terminates with a ``\r\n.

class EmailMessage(*args, **kwargs)[source]

Bases: djblets.mail.message.EmailMessage

An e-mail message.

This class only differs from Djblets’ EmailMessage by using the site configuration to generate some e-mail settings.

__init__(*args, **kwargs)[source]

Create a new EmailMessage.

Parameters
  • subject (unicode, optional) – The subject of the message. Defaults to being blank (which MTAs might replace with “no subject”.)

  • text_body (unicode, optional) – The body of the e-mail as plain text. Defaults to an empty string (allowing HTML-only e-mails to be sent).

  • html_body (unicode, optional) – The body of the e-mail as HTML. Defaults to an empty string (allowing text-only e-mails to be sent).

  • from_email (unicode, optional) – The from address for the e-mail. Defaults to DEFAULT_FROM_EMAIL.

  • to (list, optional) – A list of e-mail addresses as unicode objects that are to receive the e-mail. Defaults to an empty list of addresses (allowing using CC/BCC only).

  • cc (list, optional) – A list of e-mail addresses as unicode objects that are to receive a carbon copy of the e-mail, or None if there are no CC recipients.

  • bcc (list, optional) – A list of e-mail addresses as unicode objects that are to receive a blind carbon copy of the e-mail, or None if there are not BCC recipients.

  • sender (unicode, optional) –

    The actual e-mail address sending this e-mail, for use in the Sender header. If this differs from from_email, it will be left out of the header as per RFC 2822.

    This will default to DEFAULT_FROM_EMAIL if unspecified.

  • in_reply_to (unicode, optional) – An optional message ID (which will be used as the value for the In-Reply-To and References headers). This will be generated if not provided and will be available as the message_id attribute after the e-mail has been sent.

  • headers (django.utils.datastructures.MultiValueDict, optional) – Extra headers to provide with the e-mail.

  • auto_generated (bool, optional) – If True, the e-mail will contain headers that mark it as an auto-generated message (as per RFC 3834) to avoid auto replies.

  • prevent_auto_responses (bool, optional) – If True, the e-mail will contain headers to prevent auto replies for delivery reports, read receipts, out of office e-mails, and other auto-generated e-mails from Exchange.

  • from_spoofing (int, optional) –

    Whether to spoof the From header for the user. This can be one of FROM_SPOOFING_ALWAYS, FROM_SPOOFING_SMART, or FROM_SPOOFING_NEVER.

    This defaults to None, in which case the enable_smart_spoofing will be checked (for legacy reasons), falling back to settings.DJBLETS_EMAIL_FROM_SPOOFING (which defaults to FROM_SPOOFING_ALWAYS, also for legacy reasons).

  • enable_smart_spoofing (bool, optional) –

    Whether to enable smart spoofing of any e-mail addresses for the From header (if from_spoofing is None). This defaults to settings.EMAIL_ENABLE_SMART_SPOOFING.

    This is deprecated in favor of from_spoofing.

prepare_base_review_request_mail(user, review_request, subject, in_reply_to, to_field, cc_field, template_name_base, context=None, extra_headers=None)[source]

Return a customized review request e-mail.

This is intended to be called by one of the prepare_{type}_mail functions in this file. This method builds up a common context that all review request-related e-mails will use to render their templates, as well as handling user preferences regarding e-mail and add adding additional headers.

Parameters
  • user (django.contrib.auth.models.User) – The user who is sending the e-mail.

  • review_request (reviewboard.reviews.models.review_request.ReviewRequest) – The review request this e-mail is regarding.

  • subject (unicode) – The e-mail subject line.

  • in_reply_to (unicode) – The e-mail message ID this message is in response to or None.

  • to_field (set) – The set of User and :py:class`~reviewboard.reviews.models.group.Group`s to this e-mail will be sent to.

  • cc_field (set) – The set of User and :py:class`~reviewboard.reviews.models.group.Group`s to be CC’ed on the e-mail.

  • template_name_base (unicode) – The name of the template to use to generate the e-mail without its extension. The plain-text version of the e-mail will append .txt to this and and the rich-text version of the e-mail will append .html.

  • context (dict, optional) – Optional additional template rendering context.

  • extra_headers (dict, optional) – Optional additional headers to include.

Returns

The prepared e-mail message.

Return type

EmailMessage

prepare_password_changed_mail(user)[source]

Return an e-mail notifying the user that their password changed.

Parameters

user (django.contrib.auth.models.User) – The user whose password changed.

Returns

The generated message.

Return type

EmailMessage

prepare_reply_published_mail(user, reply, review, review_request)[source]

Return an e-mail representing the supplied reply to a review.

Parameters
Returns

The generated e-mail message.

Return type

EmailMessage

prepare_review_published_mail(user, review, review_request, request, to_owner_only=False)[source]

Return an e-mail representing the supplied review.

Parameters
Returns

The generated e-mail message.

Return type

EmailMessage

prepare_review_request_mail(user, review_request, changedesc=None, close_type=None)[source]

Return an e-mail representing the supplied review request.

Parameters
  • user (django.contrib.auth.models.User) – The user who triggered the e-mail (i.e., they published or closed he review request).

  • review_request (reviewboard.reviews.models.ReviewRequest) – The review request to send an e-mail about.

  • changedesc (reviewboard.changedescs.models.ChangeDescription) – An optional change description showing what has changed in the review request, possibly with explanatory text from the submitter. This is created when saving a draft on a public review request and will be None when publishing initially. This is used by the template to add contextual (updated) flags to inform people what has changed.

  • close_type (unicode) –

    How the review request was closed or None if it was published. If this is not None it must be one of:

Returns

The e-mail message representing the review request.

Return type

EmailMessage

prepare_user_registered_mail(user)[source]

Prepare an e-mail to the administrators notifying of a new user.

Parameters

user (django.contrib.auth.models.User) – The user who registered.

Returns

The generated e-mail.

Return type

EmailMessage

prepare_webapi_token_mail(webapi_token, op)[source]

Return an e-mail message notifying a user about a WebAPI token change.

Parameters
  • webapi_token (reviewboard.notifications.models.WebAPIToken) – The token that was created, updated, deleted, or expired.

  • op (str) –

    The operation on the token. This is one of:

    • 'created'

    • 'updated'

    • 'deleted'

    • 'expired'

Returns

The generated e-mail.

Return type

EmailMessage