4 use RT::Test tests => 66;
6 RT->Config->Set('CheckMoreMSMailHeaders', 1);
8 # 12.0 is outlook 2007, 14.0 is 2010
9 for my $mailer ( 'Microsoft Office Outlook 12.0', 'Microsoft Outlook 14.0' ) {
10 diag "Test mail with multipart/alternative";
15 To: rt\@@{[RT->Config->Get('rtname')]}
16 Subject: outlook basic test
17 Content-Type: multipart/alternative;
18 \tboundary="----=_NextPart_000_0004_01CB045C.A5A075D0"
20 ------=_NextPart_000_0004_01CB045C.A5A075D0
21 Content-Type: text/plain;
23 Content-Transfer-Encoding: 7bit
34 ------=_NextPart_000_0004_01CB045C.A5A075D0
35 Content-Type: text/html;
37 Content-Transfer-Encoding: quoted-printable
39 <html>this is fake</html>
42 ------=_NextPart_000_0004_01CB045C.A5A075D0--
52 test_email( $text, $content,
53 $mailer . ' with multipart/alternative, \n\n are replaced' );
56 diag "Test mail with multipart/mixed, with multipart/alternative in it";
61 To: rt\@@{[RT->Config->Get('rtname')]}
62 Subject: outlook basic test
63 Content-Type: multipart/mixed;
64 \tboundary="----=_NextPart_000_000F_01CB045E.5222CB40"
66 ------=_NextPart_000_000F_01CB045E.5222CB40
67 Content-Type: multipart/alternative;
68 \tboundary="----=_NextPart_001_0010_01CB045E.5222CB40"
71 ------=_NextPart_001_0010_01CB045E.5222CB40
72 Content-Type: text/plain;
74 Content-Transfer-Encoding: 7bit
85 ------=_NextPart_001_0010_01CB045E.5222CB40
86 Content-Type: text/html;
88 Content-Transfer-Encoding: quoted-printable
90 <html>this is fake</html>
92 ------=_NextPart_001_0010_01CB045E.5222CB40--
94 ------=_NextPart_000_000F_01CB045E.5222CB40
95 Content-Type: text/plain;
97 Content-Transfer-Encoding: quoted-printable
98 Content-Disposition: attachment;
101 this is the attachment! :)=0A=
103 ------=_NextPart_000_000F_01CB045E.5222CB40--
112 test_email( $text, $content,
113 $mailer . ' with multipart/multipart, \n\n are replaced' );
116 diag "Test mail with with outlook, but the content type is text/plain";
119 From: root\@localhost
121 To: rt\@@{[RT->Config->Get('rtname')]}
122 Subject: outlook basic test
123 Content-Type: text/plain; charset="us-ascii"
124 Content-Transfer-Encoding: 7bit
146 test_email( $text, $content,
147 $mailer . ' with only text/plain, \n\n are not replaced' );
150 diag "Test mail with with outlook, content type is base64";
153 From: root\@localhost
155 To: rt\@@{[RT->Config->Get('rtname')]}
156 Subject: outlook basic test
157 Content-Type: text/plain; charset="utf-8"
158 Content-Transfer-Encoding: base64
160 VGhpcyBpcyB0aGUgYm9keSBvZiBhbiBlbWFpbC4KCkl0IGhhcyBtdWx0aXBs
161 ZSBleHRyYSBuZXdsaW5lcy4KCgoKTGlrZSBhIG1hbmdsZWQgT3V0bG9vayBt
162 ZXNzYWdlIG1pZ2h0LgoKCgpKb2huIFNtaXRoCgpTb21lIENvbXBhbnkKCmVt
163 YWlsQHNvbWVjby5jb20KCg==
167 This is the body of an email.
168 It has multiple extra newlines.
170 Like a mangled Outlook message might.
176 test_email( $text, $content,
177 $mailer . ' with base64, \n\n are replaced' );
181 # In a sample we received, the two X-MS- headers included
182 # below were both present and had no values. For now, using
183 # the existence of these headers as evidence of MS Outlook
186 diag "Test mail with with outlook, no X-Mailer, content type is base64";
189 From: root\@localhost
190 To: rt\@@{[RT->Config->Get('rtname')]}
191 Subject: outlook basic test
192 Content-Type: text/plain; charset="utf-8"
193 Content-Transfer-Encoding: base64
195 X-MS-Tnef-Correlator:
197 VGhpcyBpcyB0aGUgYm9keSBvZiBhbiBlbWFpbC4KCkl0IGhhcyBtdWx0aXBs
198 ZSBleHRyYSBuZXdsaW5lcy4KCgoKTGlrZSBhIG1hbmdsZWQgT3V0bG9vayBt
199 ZXNzYWdlIG1pZ2h0LgoKCgpKb2huIFNtaXRoCgpTb21lIENvbXBhbnkKCmVt
200 YWlsQHNvbWVjby5jb20KCg==
204 This is the body of an email.
205 It has multiple extra newlines.
207 Like a mangled Outlook message might.
213 test_email( $text, $content,
214 ' with base64, no X-Mailer, \n\n are replaced' );
218 diag "Test mail with with multipart/alternative but x-mailer is not outlook ";
221 From: root\@localhost
223 To: rt\@@{[RT->Config->Get('rtname')]}
224 Subject: outlook basic test
225 Content-Type: multipart/alternative;
226 \tboundary="----=_NextPart_000_0004_01CB045C.A5A075D0"
228 ------=_NextPart_000_0004_01CB045C.A5A075D0
229 Content-Type: text/plain;
231 Content-Transfer-Encoding: 7bit
242 ------=_NextPart_000_0004_01CB045C.A5A075D0
243 Content-Type: text/html;
245 Content-Transfer-Encoding: quoted-printable
247 <html>this is fake</html>
250 ------=_NextPart_000_0004_01CB045C.A5A075D0--
263 test_email( $text, $content, 'without outlook, \n\n are not replaced' );
266 diag "Sample multipart email with Exchange headers";
269 X-MimeOLE: Produced By Microsoft Exchange V6.5
270 Received: by example.com
271 id <01CD63FC.33F4C15C\@example.com>; Tue, 17 Jul 2012 10:11:51 +0100
273 Content-Type: multipart/alternative;
274 boundary="----_=_NextPart_001_01CD63FC.33F4C15C"
275 Content-class: urn:content-classes:message
276 Subject: outlook basic test
277 Date: Tue, 17 Jul 2012 10:11:50 +0100
278 Message-ID: <AA6CEAFB02FF244999046B2A6B6B9D6F05FF9D12\@example.com>
280 X-MS-TNEF-Correlator:
281 Thread-Topic: Testing Outlook HTML
282 Thread-Index: Ac1j/DNs7ly963bnRt63SJw9DkGwyw==
283 From: root\@localhost
284 To: rt\@@{[RT->Config->Get('rtname')]}
286 This is a multi-part message in MIME format.
288 ------_=_NextPart_001_01CD63FC.33F4C15C
289 Content-Type: text/plain;
291 Content-Transfer-Encoding: quoted-printable
293 This email contains a line of text containing multiple sentences. Where
294 will RT wrap this when the text is quoted? What about the footer below?
298 This is a different line, with a blank line (paragraph) above. Will
299 there be additional blank lines when the text is quoted?
308 ------_=_NextPart_001_01CD63FC.33F4C15C
309 Content-Type: text/html;
311 Content-Transfer-Encoding: quoted-printable
313 <html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
314 xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
315 xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
316 xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
317 xmlns=3D"http://www.w3.org/TR/REC-html40"><head><META =
318 HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
319 charset=3Dus-ascii"><meta name=3DGenerator content=3D"Microsoft Word 12 =
320 (filtered medium)"><style><!--
321 /* Font Definitions */
323 {font-family:"Cambria Math";
324 panose-1:2 4 5 3 5 4 6 3 2 4;}
326 {font-family:Calibri;
327 panose-1:2 15 5 2 2 2 4 3 2 4;}
328 /* Style Definitions */
329 p.MsoNormal, li.MsoNormal, div.MsoNormal
331 margin-bottom:.0001pt;
333 font-family:"Calibri","sans-serif";}
334 a:link, span.MsoHyperlink
335 {mso-style-priority:99;
337 text-decoration:underline;}
338 a:visited, span.MsoHyperlinkFollowed
339 {mso-style-priority:99;
341 text-decoration:underline;}
343 {mso-style-type:personal-compose;
344 font-family:"Calibri","sans-serif";
347 {mso-style-type:export-only;}
350 margin:1.0in 1.0in 1.0in 1.0in;}
353 --></style><!--[if gte mso 9]><xml>
354 <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
355 </xml><![endif]--><!--[if gte mso 9]><xml>
356 <o:shapelayout v:ext=3D"edit">
357 <o:idmap v:ext=3D"edit" data=3D"1" />
358 </o:shapelayout></xml><![endif]--></head><body lang=3DEN-US link=3Dblue =
359 vlink=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal>This email =
360 contains a line of text containing multiple sentences. Where will =
361 RT wrap this when the text is quoted? What about the footer =
362 below?<o:p></o:p></p><p class=3DMsoNormal><o:p> </o:p></p><p =
363 class=3DMsoNormal>This is a different line, with a blank line =
364 (paragraph) above. Will there be additional blank lines when the =
365 text is quoted?<o:p></o:p></p><p =
366 class=3DMsoNormal><o:p> </o:p></p><p class=3DMsoNormal><span =
368 style=3D'font-size:7.5pt;font-family:"Arial","sans-serif"'>This isthesig =
369 </span><o:p></o:p></p><p =
370 class=3DMsoNormal><o:p> </o:p></p></div></body></html>
371 ------_=_NextPart_001_01CD63FC.33F4C15C--
375 This email contains a line of text containing multiple sentences. Where
376 will RT wrap this when the text is quoted? What about the footer below?
378 This is a different line, with a blank line (paragraph) above. Will
379 there be additional blank lines when the text is quoted?
385 test_email( $text, $content,
386 'Another sample multipart message with Exchange headers' );
390 my ( $text, $content, $msg ) = @_;
391 my ( $status, $id ) = RT::Test->send_via_mailgate($text);
392 is( $status >> 8, 0, "The mail gateway exited normally" );
393 ok( $id, "Created ticket" );
395 my $ticket = RT::Test->last_ticket;
396 isa_ok( $ticket, 'RT::Ticket' );
397 is( $ticket->Id, $id, "correct ticket id" );
398 is( $ticket->Subject, 'outlook basic test', "subject of ticket $id" );
399 my $txns = $ticket->Transactions;
400 $txns->Limit( FIELD => 'Type', VALUE => 'Create' );
401 my $txn = $txns->First;
403 is( $txn->Content, $content, $msg );