#1076: Can clients receive email notifications with preserved quoting?
Отредактирована: сегодняSymptoms
A client wants email notifications sent from a ticket to display all previous correspondence messages in the form of quotations.
Solution
All messages from the system are sent as a single comment, but email clients usually group them into threads that can be scrolled and viewed. It is recommended to configure the system to work in this mode.
The scenario described below can only be used with a full understanding that it will never fully imitate the work of email clients or servers, but only template messages from the ticket system in a similar way!
Below you will find a notification template that needs to be set here: Settings -> Email Template Settings -> "Ticket Notifications" tab -> The necessary template. In this particular example, we choose Any response added to my ticket **, so that clients receive emails with quoting.
This is an HTML template; do not touch the Plain text template. It is recommended to save the old template somewhere just in case, in case you need to roll back everything.
Please note that notifications with complete ticket correspondence will be received by all employees who have the "Public response added" notification enabled.
{% extends "notifications/base_email.html" %}
{% block header %}
{% if comment.is_staff %}
<p>A response was received from a support staff member. {{ comment.author.name }} writes:</p>
{% else %}
<p>Client {% if comment.author.name %}{{ comment.author.name }}{% else %}{{ comment.author.email }}{% endif %} writes:</p>
{% endif %}
{% endblock %}
{% block body %}
{{ body_html|safe }}
{% if attachments %}
<hr/>
<p>Attached files:</p>
<ul>
{% for attachment in attachments %}
<li><a href="{{ attachment.path }}">{{ attachment.name }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% if comment.sensitive_data %}
<hr/>
<p><b>The response contains confidential data that can be viewed by following the <a href="{{ instance.base_url }}/tickets/{{ ticket.id }}#comment-{{ comment.id }}">link</a></b></p>
{% endif %}
{% if ticket.comments.filter(public=True,author__is_system=False).exclude(id=comment.id).count() > 0 %}
<blockquote><p>Previous correspondence in the ticket:</p>
{% set quote_count = 0 %}
{% for quoted_comment in ticket.comments.filter(public=True, author__is_system=False).exclude(id=comment.id).order_by("-created_at") %}
<blockquote><p>{{ quoted_comment.created_at.strftime("%Y-%m-%d %H:%M:%S") }} {% if quoted_comment.is_staff %}support staff member {{ quoted_comment.author.name }} writes:</p>{% else %}client {% if quoted_comment.author.name %}{{ quoted_comment.author.name }}{% else %}{{ quoted_comment.author.email }}{% endif %} writes:</p>{% endif %}
{{ quoted_comment.body|safe }}
{% set quote_count = quote_count + 1 %}
{% endfor %}
{% for i in range(quote_count) %}
</blockquote>
{% endfor %}
</blockquote>
{% endif %}
{% endblock %}
{% block footer %}
<p>You received this notification because you are a participant in the ticket:</p>
<p><a href="{{ instance.base_url }}/tickets/{{ ticket.id }}">#{{ ticket.id }}: {{ ticket.subject }}</a></p>
<p></p>
<p>To disable this mailing list, go to your <a href="{{ instance.base_url }}/profile">personal account</a> and set up email notifications.</p>
{% endblock %}
Reason
It is important to note that Swarmica is not a complete replacement for an email server and/or client by design.
We intentionally sanitize incoming email messages, removing unnecessary quoting to avoid cluttering the ticket feed. For outgoing messages, you can configure notification templates by removing/adding additional blocks.