|
|
@@ -76,6 +76,10 @@ class EmailSender:
|
|
|
html_template : str
|
|
|
Name of the template to use as the HTML body of emails
|
|
|
if not specified in the send method.
|
|
|
+ use_jinja : bool
|
|
|
+ Use Jinja to render text/HTML. If Jinja is disabled,
|
|
|
+ images cannot be embedded to HTML, templates have no
|
|
|
+ effect and body_params are not used. Defaults True
|
|
|
templates_html : jinja2.Environment
|
|
|
Jinja environment used for loading HTML templates
|
|
|
if ``html_template`` is specified in send.
|
|
|
@@ -150,6 +154,7 @@ class EmailSender:
|
|
|
self.html = None
|
|
|
self.html_template = None
|
|
|
self.text_template = None
|
|
|
+ self.use_jinja = True
|
|
|
|
|
|
self.use_starttls = use_starttls
|
|
|
self.cls_smtp = cls_smtp
|
|
|
@@ -215,6 +220,9 @@ class EmailSender:
|
|
|
DataFrames.
|
|
|
body_params : dict, optional
|
|
|
Extra Jinja parameters passed to the HTML and text bodies.
|
|
|
+ use_jinja : bool
|
|
|
+ Use Jinja to render text/HTML. If Jinja is disabled, body content cannot be
|
|
|
+ embedded, templates have no effect and body parameters do nothing.
|
|
|
attachments : dict, optional
|
|
|
Attachments of the email. If dict value is string, the attachment content
|
|
|
is the string itself. If path, the attachment is the content of the path's file.
|
|
|
@@ -288,7 +296,8 @@ class EmailSender:
|
|
|
body_images:Optional[Dict[str, Union[str, bytes, 'plt.Figure', 'Image']]]=None,
|
|
|
body_tables:Optional[Dict[str, 'pd.DataFrame']]=None,
|
|
|
body_params:Optional[Dict[str, Any]]=None,
|
|
|
- attachments:Optional[Dict[str, Union[str, os.PathLike, 'pd.DataFrame', bytes]]]=None) -> EmailMessage:
|
|
|
+ attachments:Optional[Dict[str, Union[str, os.PathLike, 'pd.DataFrame', bytes]]]=None,
|
|
|
+ use_jinja=None) -> EmailMessage:
|
|
|
"""Get the email message"""
|
|
|
|
|
|
subject = subject or self.subject
|
|
|
@@ -302,6 +311,7 @@ class EmailSender:
|
|
|
text = text or self.text
|
|
|
html_template = html_template or self.html_template
|
|
|
text_template = text_template or self.text_template
|
|
|
+ use_jinja = self.use_jinja if use_jinja is None else use_jinja
|
|
|
|
|
|
if subject is None:
|
|
|
raise ValueError("Email must have a subject")
|
|
|
@@ -318,6 +328,7 @@ class EmailSender:
|
|
|
body = TextBody(
|
|
|
template=self.get_text_template(text_template),
|
|
|
table_template=self.get_text_table_template(),
|
|
|
+ use_jinja=use_jinja
|
|
|
)
|
|
|
body.attach(
|
|
|
msg,
|
|
|
@@ -330,6 +341,7 @@ class EmailSender:
|
|
|
body = HTMLBody(
|
|
|
template=self.get_html_template(html_template),
|
|
|
table_template=self.get_html_table_template(),
|
|
|
+ use_jinja=use_jinja
|
|
|
)
|
|
|
body.attach(
|
|
|
msg,
|