[Rt-commit] rt branch, 4.4/email-avoid-long-lines, created. rt-4.4.4-7-geed358f53
? sunnavy
sunnavy at bestpractical.com
Wed Mar 27 15:01:54 EDT 2019
The branch, 4.4/email-avoid-long-lines has been created
at eed358f53e28bee8d6f2540f13b9faf7a4951a43 (commit)
- Log -----------------------------------------------------------------
commit 43f8d97b24b4b33606eb6243974b33bd4ba4d898
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Mar 28 02:29:20 2019 +0800
Set proper transfer encoding to avoid long lines in email
According to RFC821, the maximum total length of a text line including
the <CRLF> is 1000 characters. Emails sent by RT don't always respect
this, but most mail servers could handle it quite well. Sadly that some
mail servers automatically insert "!" into long lines to indicate this
incompatibility.
This commits adds proper Content-Transfer-Encoding header to convert
messages into proper format(usually it's quoted-printable when there are
long lines) to obey RFC.
diff --git a/lib/RT/Action/SendEmail.pm b/lib/RT/Action/SendEmail.pm
index 707b0a4d4..a94aeda89 100644
--- a/lib/RT/Action/SendEmail.pm
+++ b/lib/RT/Action/SendEmail.pm
@@ -190,6 +190,14 @@ sub Prepare {
# utf-8 here is for _FindOrGuessCharset in I18N.pm
# it's not the final charset/encoding sent
$part->head->mime_attr( "Content-Type.charset" => 'utf-8' );
+
+ # Set proper transfer encoding to prevent long lines in
+ # body(1000+ chars) that are not allowed according to RFC821.
+ # Some mail servers automatically insert "!" into long lines to
+ # indicate this incompatibility.
+ if ( !$part->head->mime_attr('Content-Transfer-Encoding') ) {
+ $part->head->mime_attr( 'Content-Transfer-Encoding' => $part->suggest_encoding );
+ }
}
RT::I18N::SetMIMEEntityToEncoding(
commit eed358f53e28bee8d6f2540f13b9faf7a4951a43
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Mar 28 02:41:26 2019 +0800
Update tests for the change of email transfer encoding
Messages with non-ASCII characters will be quoted-printable encoded.
diff --git a/t/web/html_template.t b/t/web/html_template.t
index 1dbe66b00..75da593da 100644
--- a/t/web/html_template.t
+++ b/t/web/html_template.t
@@ -61,10 +61,13 @@ diag('test real mail outgoing') if $ENV{TEST_VERBOSE};
# $mail is utf8 encoded
my ($mail) = RT::Test->fetch_caught_mails;
$mail = Encode::decode("UTF-8", $mail );
- like( $mail, qr/$template.*$template/s, 'mail has template content $template twice' );
- like( $mail, qr/$subject.*$subject/s, 'mail has ticket subject $sujbect twice' );
- like( $mail, qr/$content.*$content/s, 'mail has ticket content $content twice' );
- like( $mail, qr!<h1>$content</h1>!, 'mail has ticket html content <h1>$content</h1>' );
+ my $quoted_template = MIME::QuotedPrint::encode_qp( Encode::encode( 'UTF-8', $template ), '' );
+ my $quoted_subject = MIME::QuotedPrint::encode_qp( Encode::encode( 'UTF-8', $subject ), '' );
+ my $quoted_content = MIME::QuotedPrint::encode_qp( Encode::encode( 'UTF-8', $content ), '' );
+ like( $mail, qr/$quoted_template.*$quoted_template/s, 'mail has template content $template twice' );
+ like( $mail, qr/$quoted_subject.*$quoted_subject/s, 'mail has ticket subject $sujbect twice' );
+ like( $mail, qr/$quoted_content.*$quoted_content/s, 'mail has ticket content $content twice' );
+ like( $mail, qr!<h1>$quoted_content</h1>!, 'mail has ticket html content <h1>$content</h1>' );
}
done_testing;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list