import rt 3.8.10
[freeside.git] / rt / t / mail / multipart.t
1 #!/usr/bin/perl -w
2 # BEGIN BPS TAGGED BLOCK {{{
3
4 # COPYRIGHT:
5 #  
6 # This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC 
7 #                                          <jesse.com>
8
9 # (Except where explicitly superseded by other copyright notices)
10
11
12 # LICENSE:
13
14 # This work is made available to you under the terms of Version 2 of
15 # the GNU General Public License. A copy of that license should have
16 # been provided with this software, but in any event can be snarfed
17 # from www.gnu.org.
18
19 # This work is distributed in the hope that it will be useful, but
20 # WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22 # General Public License for more details.
23
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27 # 02110-1301 or visit their web page on the internet at
28 # http://www.gnu.org/copyleft/gpl.html.
29
30
31 # CONTRIBUTION SUBMISSION POLICY:
32
33 # (The following paragraph is not intended to limit the rights granted
34 # to you to modify and distribute this software under the terms of
35 # the GNU General Public License and is only of importance to you if
36 # you choose to contribute your changes and enhancements to the
37 # community by submitting them to Best Practical Solutions, LLC.)
38
39 # By intentionally submitting any modifications, corrections or
40 # derivatives to this work, or any other work intended for use with
41 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
42 # you are the copyright holder for those contributions and you grant
43 # Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
44 # royalty-free, perpetual, license to use, copy, create derivative
45 # works based on those contributions, and sublicense and distribute
46 # those contributions and any derivatives thereof.
47
48 # END BPS TAGGED BLOCK }}}
49
50 =head1 NAME
51
52 rt-mailgate - Mail interface to RT3.
53
54 =cut
55
56 use strict;
57 use warnings;
58
59 use RT::Test tests => 5;
60 use RT::Test::Email;
61 my ($baseurl, $m) = RT::Test->started_ok;
62
63 my $queue = RT::Test->load_or_create_queue( Name => 'General' );
64 my $user  = RT::Test->load_or_create_user( Name => 'bob', EmailAddress => 'bob@example.com' );
65 $queue->AddWatcher( Type => 'AdminCc', PrincipalId => $user->PrincipalObj->Id );
66
67 my $text = <<EOF;
68 Subject: Badly handled multipart email
69 From: root\@localhost
70 To: rt\@@{[RT->Config->Get('rtname')]}
71 Content-Type: multipart/alternative; boundary=20cf3071cac0cb9772049eb22371
72
73 --20cf3071cac0cb9772049eb22371
74 Content-Type: text/plain; charset=ISO-8859-1
75
76 Hi
77
78 --20cf3071cac0cb9772049eb22371
79 Content-Type: text/html; charset=ISO-8859-1
80 Content-Transfer-Encoding: quoted-printable
81
82 <div>Hi</div>
83
84 --20cf3071cac0cb9772049eb22371--
85 EOF
86
87 my ( $status, $id ) = RT::Test->send_via_mailgate($text);
88 is( $status >> 8, 0, "The mail gateway exited normally" );
89 ok( $id, "Created ticket" );
90
91 my @msgs = RT::Test->fetch_caught_mails;
92 is(@msgs,2,"sent 2 emails");
93 diag("We're skipping any testing of the autoreply");
94
95 my $entity = parse_mail($msgs[1]);
96 is($entity->parts, 0, "only one entity");