Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Body content from incoming emails can be selectively removed in order to alter the resulting issue description or comment. Regular expressions are used to match parts of the processed email body (note that when creating regular expressions it is best to work with post-processed content from a created/commented issue).

Removing specific parts of email content

To remove only particular parts of an email's content, you will most likely want to use a Cleanup Regexp. A clean up will only remove content that matches the regular expression.


Example 1
MIME-Version: 1.0
Received: by 10.223.112.12 with HTTP; Sat, 18 Jun 2011 22:42:26 -0700 (PDT)
Date: Sun, 19 Jun 2011 17:42:26 +1200
Message-ID: <BANLkTinB1mfSh+GwOXGNWoL4SyDvOpdBoQ@mail.gmail.com>
Subject: This is a starting email template, update as required
From: "Andy Brook" <andy@localhost>
To: changeme@thiswontwork.com
Content-Type: text/plain; charset=UTF-8

Hello,

This text should stay. !!This text should be removed!! This should also stay.

Regards,
Sender


Cleanup Regexp

Resulting body


!![\w\s]*!!


Hello,

This text should stay. This should also stay.

Regards,
Sender



Example 2
MIME-Version: 1.0
Received: by 10.223.112.12 with HTTP; Sat, 18 Jun 2011 22:42:26 -0700 (PDT)
Date: Sun, 19 Jun 2011 17:42:26 +1200
Message-ID: <BANLkTinB1mfSh+GwOXGNWoL4SyDvOpdBoQ@mail.gmail.com>
Subject: This is a starting email template, update as required
From: "Andy Brook" <andy@localhost>
To: changeme@thiswontwork.com
Content-Type: text/plain; charset=UTF-8

Hello,

This text should stay. !!Keep the exclamation marks!! This should also stay.

Regards,
Sender


Cleanup Regexp

Resulting body


!!([\w\s]*)!!


Hello,

This text should stay. !!!! This should also stay.

Regards,
Sender



Removing all content from a specific point onwards

To remove all content in an email starting from one point until the end of the content, you will want to use a Body Delimiter. A delimiter removes all content from its starting point. The starting point is where the delimiter regular expression first matches.

Email signatures and all trailing text can be removed through a Create/Comment Body Delimiter:

MIME-Version: 1.0
Received: by 10.223.112.12 with HTTP; Sat, 18 Jun 2011 22:42:26 -0700 (PDT)
Date: Sun, 19 Jun 2011 17:42:26 +1200
Message-ID: <BANLkTinB1mfSh+GwOXGNWoL4SyDvOpdBoQ@mail.gmail.com>
Subject: This is a starting email template, update as required
From: "Andy Brook" <andy@test.com>
To: changeme@thiswontwork.com
Content-Type: text/plain; charset=UTF-8


some text

-- 
This is my sig

With a Create/Comment Body Delimiter that matches the line above 'This is my sig', you can remove the signature from the final body:

Create/Comment Body Delimiter

Resulting body for create

Resulting body for comment


\n-- ?\n


some text
some text

Removing old email content in replies

Things get interesting when replies to emails are handled, as there is no standard for the format of replies:

MIME-Version: 1.0
Received: by 10.223.112.12 with HTTP; Sat, 18 Jun 2011 22:42:26 -0700 (PDT)
Date: Sun, 19 Jun 2011 17:42:26 +1200
Message-ID: <BANLkTinB1mfSh+GwOXGNWoL4SyDvOpdBoQ@mail.gmail.com>
Subject: This is a starting email template, update as required
From: "Andy Brook" <andy@test.com>
To: changeme@thiswontwork.com
Content-Type: text/plain; charset=UTF-8

this is the reply

On November 1 2014, at 14:31 Andy Brook <javahollic@gmail.com> wrote:

> blah
>
> --

The Comment Only Body Delimiter Regexps are used to match these lines (only when commenting on an issue) to identify the point at which the body should be truncated.  Truncation on reply then results in just the required text being added:

Comment Only Body Delimiter

Resulting comment body


\nOn [A-Za-z]* [0-9]+ [0-9]{4}\W at [0-9]+:[0-9]+\s?(?:AM|PM)? "?.*"? <.*@.*> wrote:


this is the reply

Handling forwarded emails

When Dealing with forwarded email things get more complicated.  During create, its less likely that you would would to apply signature stripping because the first match would cause content to be truncated there and then.  During comment, its worse, because the content being forwarded looks like a reply, so would be stripped as part of the reply.

The setting Forwarded Email Subject Prefixes enables configuration of nominated email subject prefixes in a comma separated list.

Example Forwarded Email Subject Prefixes configuration

Fwd:,Fw:,WG:,Doorst:

A forwarded message such as the one below will then be processed as follows:

MIME-Version: 1.0
Received: by 10.223.112.12 with HTTP; Sat, 18 Jun 2011 22:42:26 -0700 (PDT)
Date: Sun, 19 Jun 2011 17:42:26 +1200
Message-ID: <BANLkTinB1mfSh+GwOXGNWoL4SyDvOpdBoQ@mail.gmail.com>
Subject: Fwd: This is a starting email template, update as required
From: "Andy Brook" <andy@test.com>
To: changeme@thiswontwork.com
Content-Type: text/plain; charset=UTF-8

this is a forwarded message

---------- Forwarded message ----------
From: Andy Brook <javahollic@gmail.com>
Date: 1 November 2014 14:31
Subject: hello world
To: Andy Brook <javahollic@gmail.com>


blah

-- 
This is my sig



Create

Comment

  • Subject will have any listed 'forward' prefixes removed from the subject (to be the summary)

  • Body will not be stripped

Issue Description:

this is a forwarded message

---------- Forwarded message ----------
From: Andy Brook <javahollic@gmail.com>
Date: 1 November 2014 14:31
Subject: hello world
To: Andy Brook <javahollic@gmail.com>

blah


-- 
This is THEIR sig

... further mail thread ...

-- 
This is MY sig


  • Subject is ignored, but that nature of the message being forwarded will mean:

  • Body will not be stripped

Issue Comment:

this is a forwarded message

---------- Forwarded message ----------
From: Andy Brook <javahollic@gmail.com>
Date: 1 November 2014 14:31
Subject: hello world
To: Andy Brook <javahollic@gmail.com>

blah

-- 
This is THEIR sig


... further mail thread ...
 
-- 
This is MY sig



  • No labels