Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-18566

Empty part included in mails generated from XWiki.Mail templates

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 13.2
    • Fix Version/s: None
    • Component/s: Mail
    • Labels:
      None
    • Difficulty:
      Unknown
    • Similar issues:

      Description

      XWiki.Mail objects currently support text and html parts and, regardless if any of them are empty, they will always generate 2 parts in the final email message.

      This can be problematic when the text is empty but the html is not (i.e. "html only email") because some tools that process these emails (e.g. jira when automatically creating an issue from an email) usually tend to prefer the text value, if it exists, over the html value. Normally, if no text value exists, the html value is ran through some sort of html-to-text rendering/conversion but, if the text value does exist, even if it's empty, it will be taken as it is and the html value will be discarded. Sure, it's debatable if this usecase could have been handled on the tool side as well (i.e. by Jira, in this example), but we should not be in this situation from the first place and, if we detect an empty part (e.g. text), we should not include it in the email message.

      The same logic applies for empty html parts, as we could have a "text-only" email message.

      My conclusion is that we should not include empty (not blank) parts in emails generated from template. More specifically, fix the handling done around https://github.com/xwiki/xwiki-platform/blob/5101b9c/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-send/xwiki-platform-mail-send-default/src/main/java/org/xwiki/mail/internal/factory/template/AbstractTemplateMimeBodyPartFactory.java#L78-L82

      2 questions remain:

      1. what do we do when both parts are empty? I would assume that, in this case, we would be justified to send an empty text part.
      2. what do we do if we really want to send an empty text part with our html part? I would suggest that if the user really wants to achieve this, they should add a space in their text field.

      FTR, the ideal solution would be XWIKI-10638 which would better address the usage of message parts, but, until then, the current implementation could be fixed/improved to cover the current issue.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                enygma Eduard Moraru
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Date of First Response: