Mail

SendEmail

class boilerplate.mail.SendEmail(to, subject, is_html=False, template_name_suffix=None, content=None)[source]

Send an emails or several emails easily.

Example

email = SendEmail(
    to='user@example.com',
    template_name_suffix='recover-account',
    subject='Recover your account',
    is_html=True
)
email.set_from_email('no-reply@example.com')
email.set_from_name('No Reply')
email.set_language('es')
email.add_context_data('protocol', 'https')
email.add_context_data('domain', 'example.com')
email.add_context_data('uid', uid)
email.add_context_data('token', token)
email.add_context_data('object', user)
email.add_context_data('site_name', 'Boilerplate - Make it easy')
email.send()
add_context_data(key, value)[source]

Add a key-value to the context data of the email

Parameters:
key:A valid key name
value:Can be an object or any kind of value
add_header(key, value)[source]

Add a key-value to the header of the email

Parameters:
key:A valid key name
value:Can be an object or any kind of value
set_from_email(from_email=None)[source]

Set the email sender

Parameters:
from_email:String, a valid email
set_from_name(from_name=None)[source]

Set the name sender

Parameters:
from_name:String, a valid name
set_language(language)[source]

Set the name sender

Parameters:
language:String, a valid value
set_template_name(template_name=None)[source]

Set the email template name

Parameters:
template_name:String: the name of the template without the

extension

set_template_name_suffix(template_name_suffix=None)[source]

Set the email template name suffix

Parameters:
template_name_suffix:
 String: the name of the template without the

extension