Sending Email

pretix allows event organizers to configure how they want to send emails to their users in multiple ways. Therefore, all emails should be sent through the following function.

If the email you send is related to an order, you should also take a look at the send_mail() of the order model.

pretix.base.services.mail.mail(email: str | Sequence[str], subject: str, template: str | LazyI18nString, context: Dict[str, Any] = None, event: Event = None, locale: str = None, order: Order = None, position: OrderPosition = None, *, headers: dict = None, sender: str = None, organizer: Organizer = None, customer: Customer = None, invoices: Sequence = None, attach_tickets=False, auto_email=True, user=None, attach_ical=False, attach_cached_files: Sequence = None, attach_other_files: list = None, plain_text_only=False, no_order_links=False, cc: Sequence[str] = None, bcc: Sequence[str] = None)

Sends out an email to a user. The mail will be sent synchronously or asynchronously depending on the installation.

Parameters:
  • email – The email address of the recipient

  • subject – The email subject. Should be localized to the recipients’s locale or a lazy object that will be localized by being casted to a string.

  • template – The filename of a template to be used. It will be rendered with the locale given in the locale argument and the context given in the next argument. Alternatively, you can pass a LazyI18nString and context will be used as the argument to a pretix.helpers.format.format_map(template, context) call on the template.

  • context – The context for rendering the template (see template parameter)

  • event – The event this email is related to (optional). If set, this will be used to determine the sender, a possible prefix for the subject and the SMTP server that should be used to send this email.

  • organizer – The event this organizer is related to (optional). If set, this will be used to determine the sender, a possible prefix for the subject and the SMTP server that should be used to send this email.

  • order – The order this email is related to (optional). If set, this will be used to include a link to the order below the email.

  • position – The order position this email is related to (optional). If set, this will be used to include a link to the order position instead of the order below the email.

  • headers – A dict of custom mail headers to add to the mail

  • locale – The locale to be used while evaluating the subject and the template

  • sender – Set the sender email address. If not set and event is set, the event’s default will be used, otherwise the system default.

  • invoices – A list of invoices to attach to this email.

  • attach_tickets – Whether to attach tickets to this email, if they are available to download.

  • attach_ical – Whether to attach relevant .ics files to this email

  • auto_email – Whether this email is auto-generated

  • user – The user this email is sent to

  • customer – The customer this email is sent to

  • attach_cached_files – A list of cached file to attach to this email.

  • attach_other_files – A list of file paths on our storage to attach.

  • plain_text_only – If set to True, rendering a HTML version will be skipped.

  • no_order_links – If set to True, no link to the order confirmation page will be auto-appended. Currently only allowed to use together with plain_text_only since HTML renderers add their own links.

Raises:

MailOrderException – on obvious, immediate failures. Not raising an exception does not necessarily mean that the email has been sent, just that it has been queued by the email backend.