[Rt-commit] r9649 - rt/branches/3.6-RELEASE/lib/RT/Action

audreyt at bestpractical.com audreyt at bestpractical.com
Mon Nov 12 15:48:07 EST 2007


Author: audreyt
Date: Mon Nov 12 15:48:07 2007
New Revision: 9649

Modified:
   rt/branches/3.6-RELEASE/lib/RT/Action/SendEmail.pm

Log:
* RT::Action::SendEmail - Support for multipart/* emails; we now
  textualify all MIME parts, instead of collapsing the whole multipart.

Modified: rt/branches/3.6-RELEASE/lib/RT/Action/SendEmail.pm
==============================================================================
--- rt/branches/3.6-RELEASE/lib/RT/Action/SendEmail.pm	(original)
+++ rt/branches/3.6-RELEASE/lib/RT/Action/SendEmail.pm	Mon Nov 12 15:48:07 2007
@@ -164,20 +164,24 @@
     # We should never have to set the MIME-Version header
     $self->SetHeader( 'MIME-Version', '1.0' );
 
-    # For security reasons, we only send out text/* mails.
-    my $content_type = $MIMEObj->mime_type;
-    $content_type =~ s/;.*//;
-    $content_type = 'text/plain' unless ( $content_type =~ m{^text/} );
-
-    # try to convert message body from utf-8 to $RT::EmailOutputEncoding
-    $self->SetHeader( 'Content-Type', $content_type.'; charset="utf-8"' );
-
     # fsck.com #5959: Since RT sends 8bit mail, we should say so.
     $self->SetHeader( 'Content-Transfer-Encoding','8bit');
 
-    RT::I18N::SetMIMEEntityToEncoding( $MIMEObj, $RT::EmailOutputEncoding,
-        'mime_words_ok' );
-    $self->SetHeader( 'Content-Type', $content_type.'; charset="' . $RT::EmailOutputEncoding . '"' );
+    # For security reasons, we only send out textual mails.
+    my @parts = $MIMEObj;
+    while (my $part = shift @parts) {
+        if ($part->is_multipart) {
+            push @parts, $part->parts;
+        }
+        else {
+            $part->head->mime_attr( "Content-Type" => 'text/plain' )
+                unless RT::I18N::IsTextualContentType($part->mime_type);
+            $part->head->mime_attr( "Content-Type.charset" => 'utf-8' );
+        }
+    }
+
+
+    RT::I18N::SetMIMEEntityToEncoding( $MIMEObj, $RT::EmailOutputEncoding, 'mime_words_ok' );
 
     # Build up a MIME::Entity that looks like the original message.
     $self->AddAttachments() if ( $MIMEObj->head->get('RT-Attach-Message') );


More information about the Rt-commit mailing list