@@ -218,10 +218,12 @@ Sending emails
218218``openwisp_utils.admin_theme.email.send_email ``
219219+++++++++++++++++++++++++++++++++++++++++++++++
220220
221- This function allows sending email in both plain text and HTML version
222- (using the template and logo that can be customized using
223- :ref: `OPENWISP_EMAIL_TEMPLATE <openwisp_email_template >` and
224- :ref: `OPENWISP_EMAIL_LOGO <openwisp_email_logo >` respectively).
221+ This function enables sending emails in both plain text and HTML formats.
222+ The HTML version uses a customizable template and logo.
223+
224+ You can set the logo using the :ref: `OPENWISP_EMAIL_LOGO
225+ <openwisp_email_logo>` setting. To override the default template, see
226+ :ref: `Customizing Email Templates <utils_send_email >`.
225227
226228In case the HTML version if not needed it may be disabled by setting
227229:ref: `OPENWISP_HTML_EMAIL <openwisp_html_email >` to ``False ``.
@@ -242,7 +244,7 @@ In case the HTML version if not needed it may be disabled by setting
242244 ``call_to_action_text `` and ``call_to_action_url `` can be passed to show a call to action
243245 button. Similarly, ``footer `` can be passed to add a footer.
244246``html_body_template `` **(optional, str) ** The path to the template used for generating the HTML version. By
245- default, it uses the template specified in :ref: ` openwisp_email_template `.
247+ default, it uses `` openwisp_utils/email_template.html ` `.
246248``**kwargs `` Any additional keyword arguments (e.g. ``attachments ``, ``headers ``, etc.) are passed
247249 directly to the `django.core.mail.EmailMultiAlternatives
248250 <https://docs.djangoproject.com/en/4.1/topics/email/#sending-alternative-content-types> `_.
@@ -252,3 +254,35 @@ In case the HTML version if not needed it may be disabled by setting
252254
253255 Data passed in body should be validated and user supplied data should
254256 not be sent directly to the function.
257+
258+ Customizing Email Templates
259+ +++++++++++++++++++++++++++
260+
261+ To customize the email templates used by the :ref: `utils_send_email `
262+ function, you can override the ``openwisp_utils/email_template.html ``
263+ template in your Django project. Create a template with the same path
264+ (``openwisp_utils/email_template.html ``) in your project's template
265+ directory to override the default template.
266+
267+ It is recommended to extend the default email template as shown below:
268+
269+ .. code-block :: django
270+
271+ {% extends 'openwisp_utils/email_template.html' %}
272+ {% block styles %}
273+ {{ block.super }}
274+ <style>
275+ .body {
276+ height: 100%;
277+ background: linear-gradient(to bottom, #8ccbbe 50%, #3797a4 50%);
278+ background-repeat: no-repeat;
279+ background-attachment: fixed;
280+ padding: 50px;
281+ }
282+ </style>
283+ {% endblock styles %}
284+
285+ Similarly, you can customize the HTML of the template by overriding the
286+ ``body `` block. See `email_template.html
287+ <https://github.com/openwisp/openwisp-utils/blob/master/openwisp_utils/admin_theme/templates/openwisp_utils/email_template.html> `_
288+ for reference implementation.
0 commit comments