Reference¶
- mail_builder.build_message(template_names, extra_context=None, force_multipart=False, **defaults)¶
Constructs a
EmailMessageusing the template to provide arguments.- Parameters:
template_names (sequence) – A list of template names to pass to
select_template. If a single string is passed, it will be wrapped in a listextra_context (dict) – Extra context to pass to the template blocks.
force_multipart (bool) – Ensure a
EmailMultipartMessageis built, even when no hmtl content is provided.defaults (varied) – All extra arguments will be passed to the
EmailMessage
- Returns:
EmailMessageinstance.
- class mail_builder.views.EmailFormMixin¶
A mixin intended for
FormViewwhich renders and sends an email on form valid.- email_template¶
The value to pass as email_templates to build_message
- fail_silently¶
(Default: True)
Passed to
EmailMessage.send
- email_kwargs¶
(Default: {})
Arguments to pass when calling build_message
- get_email_context(form, **kwargs)¶
Hook to build the context to be used when rendering email template blocks. The default implementation will return
kwargs, after setting ‘form’ to the form’scleaned_data, if it’s not set.
- get_email_kwargs(form, **kwargs)¶
Builds the dict of keyword arguments to pass to build_message.
The default implementation updates kwargs from
self.email_kwargs.
- form_valid(form)¶
Calls self.get_email_context and self.get_email_kwargs, then builds a message using build_message. Then calls
send(fail_silently=self.fail_silently)on the message. Finally calls the superclass’sform_validmethod.