Handling signatures, replies and forwarded messages

Introduction

JEMH Cloud has features that allow email content to be removed before it is used to create (or comment on) Jira issues.

As a simple example, the body of an email may contain a signature from the sender:

This is my email which contains a basic signature! -- Robert Smith Smith & Sons Bakery Fine foods since 1897

When creating an issue, removing this may be desirable - but it depends! If the majority of your users are external, leaving this data available can be convenient for things such as telephone number or address. On the other hand, if most of your users are internal then the nearly identical signatures may be unwanted.

Removing all content after a specific point

Content can be removed from a configured part of an email onwards. In JEMH, these are called Delimiters. Inside a JEMH project mapping, you will find the following settings under the Pre-processing section:

Setting

Value

Description

Setting

Value

Description

Create Body Delimiter Texts

Comment Body Delimiter Texts

Custom regular expressions or text

Multiple user editable regular expressions or text strings can be entered to to strip signatures and other 'trailing' content that is not required.

Regular expressions may not use .* and must create a more accurate expression .

All expressions are prefixed with a newline (\n) behind the scenes so that should not be included.

If you want to match the literal characters . or *, they must be escaped using \. or \* , its possible to use a hex code to match the character, e.g. \x2E for . See https://en.wikipedia.org/wiki/ASCII for a full list of Hex codes.

Create Body Delimiter Regexes

Comment Body Delimiter Regexes

Built-in regular expressions or text

Patterns that are found to frequently occur in real life use. They are used to strip signatures and other 'trailing' content that is not required.

Creating a Test Case

Typically, you may wish to remove content such as email signatures during issue creation - lets use this as an example.

First, you will need to locate an example Test Case in order to verify configuration.  JEMH stores recently received content in the database (encrypted!) which makes doing what comes next possible, use Auditing > Inbound Message to locate an example message, select the Generate Test Case action:

Approve:

Go to the Test Case

This Test Case will be used to validate the truncation:

The intent here is to strip the content after the -- which is the standard way to identify a signature block BUT is still prone to false matching (when content contains -- on a new line prior to the signature block, which matches first, causing premature truncation .  Edit the Test Case if needed, the content stripping here will not run the test case, just extract content.

Go the pre-processing section of the profile

Locate the profile required, hit the configure icon:

Then click Project Mappings to see the Default Mapping from which all others 'inherit', here we'll configure that so all Mappings get the same behaviour:

Now select Pre-Processing, then edit the section:

Reviewing the Pre-Processing Section

As emails can contain both text and HTML, preferring HTML over text would be needed for example to ensure the Wiki Markup conversion applies:

Preview output

Further down the screen there is an Email Body Regex Tester, click it to expand:

In it, the Test Case created earlier can be selected, the mode chose (default to create), the email test case is shown (click the + to go full screen edit), on expand, it will automatically run, showing what the 'body' will be after applying all the expressions that are shown.  Edits made to these expressions can be evaluated without saving, by just hitting the Test button.  Here, you'll see the signature text shown in the content block is gone, this was done through a canned expression.  When signature text does not start in this way, a user defined expression is needed, for example (NOTE: leading empty line!)

  Met vriendelijke groet, Mr Manager Applicatie beheer

To match that a user expression like this will be needed to achieve the same result:

 When converting HTML Mail, remember that as part of converting HTML to text, some newline injection may occur and is variable (changing your newlines may result in a non-matching expression!)

Removing sections of email content

Rather than removing everything from one point onwards, you may need to instead just remove a particular section. This is done using Clean-ups. Like the previously mentioned Delimiters, Clean-ups are found in the Pre-processing section of project mappings.

Setting

Value

Description

Setting

Value

Description

Pre Field Processor Body Clean-up Regexes

Custom regular expressions or text

Multiple user editable regular expressions or text strings can be entered to to strip signatures and other 'trailing' content that is not required.

Regular expressions may not use .* and must create a more accurate expression . All expressions are prefixed with a newline (\n) behind the scenes so that should not be included.

Create Post Field Processor Body Clean-up Regexes

Comment Post Field Processor Body Clean-up Regexes

Built-in regular expressions or text

Patterns that are found to frequently occur in real life use. They are used to strip signatures and other 'trailing' content that is not required.

As an example, say that we want to remove the legal paragraph from the signatures below:

Subject: This is a simple mail From: Andy Brook <andy@thepluginpeople.com> To: PPL Support <support@thepluginpeople.com> Content-Type: text/plain this is a forwarded message ---------- Forwarded message ---------- From: Andy Brook <javahollic@gmail.com> Date: 1 November 2014 14:31 Subject: AAAAAAAAAA To: Andy Brook <javahollic@gmail.com> 1 this is the payload Met vriendelijke groet, Mr Manager Applicatie beheer This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. ---------- Forwarded message ---------- From: Andy Brook <javahollic@gmail.com> Date: 1 November 2014 14:31 Subject: BBBBBBBB To: Andy Brook <javahollic@gmail.com> 1 this is the payload Met vriendelijke groet, Mr Manager Applicatie beheer This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

So, we will make an expression that will match that signature, using the JEMHC Regexp Tester to make sure it works. Here we use the leading and trailing text, with a regex in the middle covering expected characters:

When this is set (and other expressions such as \n-- ?\n are removed) :

When tested, the matching content is removed and the content is cleaned up:

Forwarded emails

JEMH also has this same feature, whereby, subject prefixes that match known 'forwarded mail' will be detected, and will not have body delimiter stripping applied but will have selective content removal applied, to enable better forwarded mail results.  This behaviour will be consistent for Create and Comment, currently, content is only retained on Create, forwarding a mail into an existing issue will get truncated.

In this example we are using the Create Post Field Processor Body Clean-up Regex to strip out unwanted header data from an email we are forwarding. Here is what our incoming email looks like:

To strip out the forwarded message header, we are using the following regex:

Here is the setting in JEMHC:

When this email is run as a test case against our profile, we see the following result: