[rt-users] In Line Images in Emails

Kevin Curtis Kevin.Curtis at farsite.com
Mon Jun 2 04:48:03 EDT 2014


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/&/&/g;

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

                $content =~ s/>/>/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.





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



On Fri, May 30, 2014 at 11:57:22AM +0100, Kevin Curtis wrote:

>

>    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 <pre> .. </pre> block.



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



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 at easter-eggs.com  -   http://www.easter-eggs.com

--

RT Training - Boston, September 9-10

http://bestpractical.com/training
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20140602/dfcfa83c/attachment.htm>


More information about the rt-users mailing list