In Line Images in Emails

Hi,
I have searched hard for the answer to this one, but there seems to be some confusion. I am hoping that someone can provide some definitive answers.

We have RT version 4.2.1 installed on Ubuntu 12.04. The main mailbox is on a Windows Exchange server, and we use fetchmail to get the mail every minute or so. Mail sent by RT goes through sendmail.

We use RT as a Ticket handling tool for customer problems. Our inhouse support staff use Office Outlook version 12. The email client composes html formatted email.

We have found that whenever RT receives an email that contains an inline image (internally or externally), any emails that get sent out by RT (for example to the CC list or the requestor or the owner) the email that gets sent out has the text/html section stripped of any html formatting and the text is encased in a

block.
There is not an image either.

The email can be viewed in the Web GUI as it was sent by the originator. The reformatting is performed by RT when generating the outgoing mail.

If the email had contained a url to an image instead of an embedded image, then all seems to work fine. In this case the outgoing emails are not converted to plain text in a text/html wrapper.

So my questions are as follows:

  1.  Is there any documentation anywhere about the limitations of using the email interface?
    
  2.  Should the email with an embedded image in it have not had the html formatting stripped out?
    
  3.  Have I misconfigured something?
    

The questions
Thanks in Advance

Kevin Curtis
Farsite Communications.

We have found that whenever RT receives an email that contains an inline
image (internally or externally), any emails that get sent out by RT (for
example to the CC list or the requestor or the owner) the email that gets
sent out has the text/html section stripped of any html formatting and the
text is encased in a

block.

html/body is stripped in RT::Transaction->Content, but not wrapped in

 ...

can you send more information (test case) for this problem?

> 
>    There is not an image either.
> 

The problem appears when the image is referenced as src="cid:...". There is a
bug caused by the fact that RT changes multipart/related to
multipart/mixed that breaks displaying of inline images.


I worked a bit on this but did not found a beautiful fix (as a template
may makes reference to another Transaction content than the current one
...).

A quick fix is to hack RT::Transaction::Content so it looks for CIDs,
then try to find corresponding images attachments in
RT::Tickets->Attachments, then replaced the CID by
src="data:image...".


Easter-eggs                              Spécialiste GNU/Linux
44-46 rue de l'Ouest  -  75014 Paris  -  France -  Métro Gaité
Phone: +33 (0) 1 43 35 00 37    -   Fax: +33 (0) 1 43 35 00 76
mailto:elacour@easter-eggs.com  -   http://www.easter-eggs.com

Hi Emmanuel,

Thanks for your reply.

The test case for us was quite simple. We use Miscrosoft Office Outlook as the email client.

1) Create a ticket

2) The Ticket owner updates the ticket by sending an email to RT that has

   an inline image

3) RT sends an email to the Requestor and CC's that has been converted to plain text

We believe that the plain text conversion was taking place in Transaction.pm here (highlighted):

my $content;

if ( my $content_obj =

    $self->ContentObj( $args{Type} ? ( Type => $args{Type} ) : () ) )

{

    $content = $content_obj->Content ||'';



    $RT::Logger->debug( "From Transaction.pm args{type} is ".$args{Type} );

    $RT::Logger->debug( "but the detected object type of the content is ".$content_obj->ContentType );



    if ( lc $content_obj->ContentType eq 'text/html' ) {

if ( 1 ) {

        $content =~ s/<p>--\s+<br \/>.*?$//s if $args{'Quote'};



        if ($args{Type} ne 'text/html') {

        $RT::Logger->error( "In content type is html ".$args{Type} );

            $content = RT::Interface::Email::ConvertHTMLToText($content);

        }

    }

    else {

        $content =~ s/\n-- \n.*?$//s if $args{'Quote'};

        if ($args{Type} eq 'text/html') {

            # Extremely simple text->html converter

            $content =~ s/&/&#38;/g;

            $content =~ s/</&lt;/g;

            $content =~ s/>/&gt;/g;

            $content = "<pre>$content</pre>";

        }

    }

}

We also think that we have solved the issue with a modification as follows:

    my $all_parts = $self->Attachments;
  •    while ( my $part = $all_parts->Next ) {
    

+# $RT::Logger->debug("Detected a part in the multipart of type ".$part->ContentType);

  •        if ( lc $part->ContentType eq 'text/html' ) {
    
  •            return $part;
    
  •        }
    
  •        next;
    
  •    }
    
    
    
      while ( my $part = $all_parts->Next ) {
    
          next unless RT::I18N::IsTextualContentType($part->ContentType)
    
                      && $part->Content;
    

$RT::Logger->debug(“Figured this part of type “.$part->ContentType.” would do you”);

        return $part;

    }

Could you confirm that this code change is appropriate.

Regards

Kevin Curtis

FarSite Communications.From: rt-users [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Emmanuel Lacour
Sent: 30 May 2014 17:32
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] In Line Images in Emails

We have found that whenever RT receives an email that contains an inline

image (internally or externally), any emails that get sent out by RT (for

example to the CC list or the requestor or the owner) the email that gets

sent out has the text/html section stripped of any html formatting and the

text is encased in a

block.

html/body is stripped in RT::Transaction->Content, but not wrapped in

can you send more information (test case) for this problem?

There is not an image either.

The problem appears when the image is referenced as src=“cid:…”. There is a bug caused by the fact that RT changes multipart/related to multipart/mixed that breaks displaying of inline images.

I worked a bit on this but did not found a beautiful fix (as a template may makes reference to another Transaction content than the current one …).

A quick fix is to hack RT::Transaction::Content so it looks for CIDs, then try to find corresponding images attachments in RT::Tickets->Attachments, then replaced the CID by src=“data:image…”.

Easter-eggs Spécialiste GNU/Linux

44-46 rue de l’Ouest - 75014 Paris - France - Métro Gaité

Phone: +33 (0) 1 43 35 00 37 - Fax: +33 (0) 1 43 35 00 76

mailto:elacour@easter-eggs.com - http://www.easter-eggs.com

RT Training - Boston, September 9-10

http://bestpractical.com/training

Hi Emmanuel,

The test case for us was quite simple. We use Miscrosoft Office Outlook
as the email client.

   1) Create a ticket

   2) The Ticket owner updates the ticket by sending an email to RT that

has

      an inline image

   3) RT sends an email to the Requestor and CC’s that has been converted

to plain text

So it looks that your Template that is used to send this email is not
using something like:

RT-Attach-Message: yes
Content-Type: text/html

[…]

{$Transaction->Content( Type => “text/html”)}

Easter-eggs Spécialiste GNU/Linux
44-46 rue de l’Ouest - 75014 Paris - France - Métro Gaité
Phone: +33 (0) 1 43 35 00 37 - Fax: +33 (0) 1 43 35 00 76
mailto:elacour@easter-eggs.com - http://www.easter-eggs.com

Hi,
The Template for Correspondence is as you show below, as does the one for Transaction. Is there another that I should check?

Regards

Kevin-----Original Message-----
From: Emmanuel Lacour [mailto:elacour@easter-eggs.com]
Sent: 02 June 2014 10:07
To: Kevin Curtis
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] In Line Images in Emails

On Mon, Jun 02, 2014 at 09:48:03AM +0100, Kevin Curtis wrote:

Hi Emmanuel,

The test case for us was quite simple. We use Miscrosoft Office Outlook
as the email client.

   1) Create a ticket

   2) The Ticket owner updates the ticket by sending an email to RT that

has

      an inline image

   3) RT sends an email to the Requestor and CC’s that has been converted

to plain text

So it looks that your Template that is used to send this email is not using something like:

RT-Attach-Message: yes
Content-Type: text/html

[…]

{$Transaction->Content( Type => “text/html”)}

Easter-eggs Spécialiste GNU/Linux
44-46 rue de l’Ouest - 75014 Paris - France - Métro Gaité
Phone: +33 (0) 1 43 35 00 37 - Fax: +33 (0) 1 43 35 00 76
mailto:elacour@easter-eggs.com - http://www.easter-eggs.com

Hi,
The Template for Correspondence is as you show below, as does the one for Transaction. Is there another that I should check?

and your scrip is really using this template or the non-html one?

Easter-eggs Spécialiste GNU/Linux
44-46 rue de l’Ouest - 75014 Paris - France - Métro Gaité
Phone: +33 (0) 1 43 35 00 37 - Fax: +33 (0) 1 43 35 00 76
mailto:elacour@easter-eggs.com - http://www.easter-eggs.com

Yes I believe so.
For example, scrip 12 references the Template Correspondence. And that template is using text/html.

I note that there is a “Correspondence” and a “Correspondence in HTML” template and both appear to be the same. I did read that there is a script to convert text/pain templates to text/html templates, does it do anything else that might be significant? I am not sure if that script has been run or if the Templates were changes manually. Does the Global/Templates list normally show the “Template” and the “Template in HTML” entries?

Regards

Kevin-----Original Message-----
From: Emmanuel Lacour [mailto:elacour@easter-eggs.com]
Sent: 02 June 2014 11:03
To: Kevin Curtis
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] In Line Images in Emails

On Mon, Jun 02, 2014 at 10:27:07AM +0100, Kevin Curtis wrote:

Hi,
The Template for Correspondence is as you show below, as does the one for Transaction. Is there another that I should check?

and your scrip is really using this template or the non-html one?

Easter-eggs Spécialiste GNU/Linux
44-46 rue de l’Ouest - 75014 Paris - France - Métro Gaité
Phone: +33 (0) 1 43 35 00 37 - Fax: +33 (0) 1 43 35 00 76
mailto:elacour@easter-eggs.com - http://www.easter-eggs.com