Is it possible to include line breaks in activities created from inbound emails, given that this is implemented in CiviCase? If so are there any suggestions about how to go about implementing this?

Currently long emails, especially if replies are included result in a confusing block of text. This has previously been noted at Inbound Email - Formatting? (emails with HTLM code are ignored), However if the activity is saved to a case and then viewed the line breaks are shown.

To reproduce. - Send an email (with line breaks/paragraphs) that will be recorded as an activity (https://civicrm.org/blog/dahndy/leveraging-civicrm-email-to-activity-processing-in-gmail details how to with gmail) - View the associated activity on the associated contact (search for the email you send the email from) - Note that the email has line breaks/paragraphs removed. - Assign the email activity to a case - View the case - scroll down to the activites tab - view - The same content will be displayed with line breaks.

My understanding is that the contact record Activity View uses the following to display the body of the email: {$values.details|crmStripAlternatives|nl2br} civicrm-core/templates/CRM/Activity/Form/ActivityView.tpl:138

Where as the CiviCase Activity view is using: {$form.details.html} civicrm-core/templates/CRM/Case/Form/Activity.tpl :64

In the database the detail field for inbound email the record is stored as two ALTERNATIVE ITEM's the first as plain text with line breaks, the second with the full html of the inbound email.

  • The "nl2br" part is intended to make the line breaks display. I'm not sure why it wouldn't be since you say the database first part has line breaks. For civicase I'm not sure that's the correct line in the file, but anyway I'd start by looking into whether the br's are actually being output in the underlying view-source for the non-case ones.
    – Demerit
    Feb 15, 2018 at 1:34
  • Hey Luke, I would like to answer this question in a helpful way but am having trouble doing so. The only question you have asked is "is it possible" and from what you wrote afterwards, I think you know that the answer is Yes :) Are you wanting to make the changes yourself and are stuck at a certain point? Is there anything else specific that you want to know the answer to? Feb 15, 2018 at 10:19
  • I've edited question. Basically I'm keen to have a go at digging into this further in the code. I assume that there is probably some disparity between how line breaks are being handled - or it's getting the wrong part of the email from the crmStripAlternatives function. Feb 18, 2018 at 21:07

1 Answer 1


This bug has been fixed in RC 4.7.31 -> https://github.com/civicrm/civicrm-core/pull/11661

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.