From Request Tracker Wiki
Jump to navigation Jump to search

If you are running RT 3.8.2, please see docs/templates.pod in the extracted distribution for RT's support for HTML mail. You can also read that document in subversion(

This is a modification of RT::Action::SendEmail, which it will allow to RT to send mails not only with Content-Type: text/plain.

How is it working???

When you are editing a template, if you want that the outgoing mails using that template have other "Content-Type", you should add at the beginning of the template the mail header, and RT will care about the new value of the content-type.

For example: If we want to send outgoing html mails, you should add to the template the following sentence:

Content-Type: text/html

The patch has been developed for RT 3.6.4, so please take care if you are going to run it over other version of RT.

--- lib/RT/Action/ 2007-05-25 22:16:34.000000000 +0200 +++ lib/RT/Action/ 2008-02-04 18:08:58.000000000 +0100 @@ -155,8 +155,13 @@

# We should never have to set the MIME-Version header $self->SetHeader( 'MIME-Version', '1.0' );

@@ -164,8 +169,11 @@

RT::I18N::SetMIMEEntityToEncoding( $MIMEObj, $RT::EmailOutputEncoding,

    'mime_words_ok' );

@@ -722,6 +730,30 @@

# }}}

+# {{{ sub GetContentType + +=head2 GetContentType + +This routine sets the subject. it does not add the rt tag. that gets done elsewhere +If $self->{'Subject'} is already defined, it uses that. otherwise, it tries to get +the transaction's subject. + +=cut + +sub GetContentType { + my $self = shift; + my $subject; + + my $message = $self->TransactionObj->Attachments; + if ( $self->TemplateObj->MIMEObj->head->get('Content-Type') ) { + my $value = $self->TemplateObj->MIMEObj->head->get('Content-Type'); + chop($value); + return $value ; + } + return undef; +} + +# }}}

# {{{ sub SetSubject


Later Versions

I was not able to get this working under 3.8.1 with the above method. Instead I made changes to lib/RT/Template_Overlay . Here are the changes: Comment this passage on line 322:

if (defined $mime_type and $mime_type eq 'text/html') {


On line 456 change the mime type from text/plain to text/html:

$new_entity->head->mime_attr( "Content-Type" => 'text/html' );

Note that this doesn't really preserve flexibility in what format you're sending your messages in. There is almost certainly a better way to do this.

One other comment: Anything submitted from the web interface is going to be stripped of certain tags. If you want to change this, and understand the security implications thereof, you can configure the scrubber in /html/Elements/ScrubHTML .