cdh.core.utils.mail module
- cdh.core.utils.mail.send_personalised_mass_mail(datatuple: List[Tuple[str, dict, List[str]]], template: str, template_context: dict, from_email: str = None, plain_context: dict = None, html_context: dict = None, language: str = 'nl') None [source]
Given a datatuple of (subject, personal_context, recipient_list), send each message to each recipient list.
personal_context and template_context will be merged together to create a personalised email.
html_context and plain_context can be used to override something in the regular template_context for either the html version of the plain text version. (Note: you can also add a key that does not exist in template_context)
- Parameters
datatuple – A tuple of tuples: (subject, personal_context, recipient_list)
template – Template name, without extension
template_context – Any context variables for the templates
from_email – FROM header. If absent, settings.FROM_EMAIL will be used
html_context – Optional dict with context specifically for HTML
plain_context – Optional dict with context specifically for plaintext
language – Which language Django should use when creating the mail
Deprecated since version 3.0: Replaced by cdh.core.mail package
- cdh.core.utils.mail.send_template_email(recipient_list: list, subject: str, template: str, template_context: dict, from_email: str = None, plain_context: dict = None, html_context: dict = None, language: str = 'nl') None [source]
Light wrapper for Django’s send_mail function. The main addition: this function handles the template rendering for you. Just specify the template name (without extensions).
Note: both a HTML and a plain text version of the template should exist!
For example: app/test.html app/test.txt
Function call: send_template_email(template=’app/test’, *args, **kwargs)
html_context and plain_context can be used to override something in the regular template_context for either the html version of the plain text version. (Note: you can also add a key that does not exist in template_context)
- Parameters
recipient_list – A list of recipients
subject – Email subject
template – Template name, without extension
template_context – Any context variables for the templates
from_email – FROM header. If absent, settings.FROM_EMAIL will be used
html_context – Optional dict with context specifically for HTML
plain_context – Optional dict with context specifically for plaintext
language – Which language Django should use when creating the mail
Deprecated since version 3.0: Replaced by cdh.core.mail package