1 | /**************************************************************** |
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one * |
---|
3 | * or more contributor license agreements. See the NOTICE file * |
---|
4 | * distributed with this work for additional information * |
---|
5 | * regarding copyright ownership. The ASF licenses this file * |
---|
6 | * to you under the Apache License, Version 2.0 (the * |
---|
7 | * "License"); you may not use this file except in compliance * |
---|
8 | * with the License. You may obtain a copy of the License at * |
---|
9 | * * |
---|
10 | * http://www.apache.org/licenses/LICENSE-2.0 * |
---|
11 | * * |
---|
12 | * Unless required by applicable law or agreed to in writing, * |
---|
13 | * software distributed under the License is distributed on an * |
---|
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * |
---|
15 | * KIND, either express or implied. See the License for the * |
---|
16 | * specific language governing permissions and limitations * |
---|
17 | * under the License. * |
---|
18 | ****************************************************************/ |
---|
19 | |
---|
20 | package org.apache.james.mime4j; |
---|
21 | |
---|
22 | import java.nio.charset.Charset; |
---|
23 | import java.util.Locale; |
---|
24 | |
---|
25 | import org.apache.james.mime4j.util.CharsetUtil; |
---|
26 | |
---|
27 | public class ExampleMail { |
---|
28 | |
---|
29 | public static final String MIME_MULTIPART_EMBEDDED_MESSAGES_INNER_MULTIPART_MIXED = "--4.66920160910299\r\n" + |
---|
30 | "Content-Type: image/gif\r\n" + |
---|
31 | "Content-Transfer-Encoding: base64\r\n" + |
---|
32 | "MIME-Version: 1.0\r\n" + |
---|
33 | "Content-ID: 238478934723847238947892374\r\n" + |
---|
34 | "Content-Description: Bogus Image Data\r\n" + |
---|
35 | "\r\n" + |
---|
36 | "ABCDFEGHIJKLMNO\r\n" + |
---|
37 | "\r\n" + |
---|
38 | "--4.66920160910299\r\n" + |
---|
39 | "Content-Type: message/rfc822\r\n" + |
---|
40 | "\r\n" + |
---|
41 | "From: Timothy Tayler <timothy@example.org>\r\n" + |
---|
42 | "To: John Smith <john@example.org>\r\n" + |
---|
43 | "Date: Sat, 16 Feb 2008 12:00:00 +0000 (GMT)\r\n" + |
---|
44 | "Subject: Another Example Email\r\n" + |
---|
45 | "Content-Type: multipart/mixed;boundary=2.50290787509\r\n" + |
---|
46 | "\r\n" + |
---|
47 | "Yet another preamble\r\n" + |
---|
48 | "\r\n" + |
---|
49 | "--2.50290787509\r\n" + |
---|
50 | "Content-Type: text/plain\r\n" + |
---|
51 | "\r\n" + |
---|
52 | "Rhubard AND Custard!\r\n" + |
---|
53 | "\r\n" + |
---|
54 | "--2.50290787509\r\n" + |
---|
55 | "Content-Type: multipart/alternative;boundary=3.243F6A8885A308D3\r\n" + |
---|
56 | "\r\n" + |
---|
57 | "--3.243F6A8885A308D3\r\n" + |
---|
58 | "Content-Type: text/plain\r\n" + |
---|
59 | "\r\n" + |
---|
60 | "Rhubard?Custard?\r\n" + |
---|
61 | "\r\n" + |
---|
62 | "--3.243F6A8885A308D3\r\n" + |
---|
63 | "\r\n" + |
---|
64 | "Content-Type: text/richtext\r\n" + |
---|
65 | "\r\n" + |
---|
66 | "Rhubard?Custard?\r\n" + |
---|
67 | "\r\n" + |
---|
68 | "--3.243F6A8885A308D3--\r\n" + |
---|
69 | "\r\n" + |
---|
70 | "--2.50290787509--\r\n" + |
---|
71 | "\r\n" + |
---|
72 | "--4.66920160910299--"; |
---|
73 | |
---|
74 | public static final String MIME_MULTIPART_EMBEDDED_MESSAGES_INNER_MAIL = "From: Timothy Tayler <timothy@example.org>\r\n" + |
---|
75 | "To: Samual Smith <samual@example.org>\r\n" + |
---|
76 | "Date: Thu, 14 Feb 2008 12:00:00 +0000 (GMT)\r\n" + |
---|
77 | "Subject: A Multipart Alternative Email\r\n" + |
---|
78 | "Content-Type: multipart/alternative;boundary=42\r\n" + |
---|
79 | "\r\n" + |
---|
80 | "This message has a premable\r\n" + |
---|
81 | "\r\n" + |
---|
82 | "--42\r\n" + |
---|
83 | "Content-Type: text/plain; charset=US-ASCII\r\n" + |
---|
84 | "\r\n" + |
---|
85 | "Custard!\r\n" + |
---|
86 | "\r\n" + |
---|
87 | "--42\r\n" + |
---|
88 | "Content-Type: application/octet-stream\r\n" + |
---|
89 | "\r\n" + |
---|
90 | "CUSTARDCUSTARDCUSTARD\r\n" + |
---|
91 | "\r\n" + |
---|
92 | "--42--\r\n"; |
---|
93 | |
---|
94 | public static final String MIME_MULTIPART_EMBEDDED_MESSAGES_BODY = "Start with a preamble\r\n" + |
---|
95 | "\r\n" + |
---|
96 | "--1729\r\n" + |
---|
97 | "Content-Type: text/plain; charset=US-ASCII\r\n" + |
---|
98 | "\r\n" + |
---|
99 | "Rhubarb!\r\n" + |
---|
100 | "\r\n" + |
---|
101 | "--1729\r\n" + |
---|
102 | "Content-Type: application/octet-stream\r\n" + |
---|
103 | "Content-Transfer-Encoding: base64\r\n" + |
---|
104 | "\r\n" + |
---|
105 | "987654321AHPLA\r\n" + |
---|
106 | "\r\n" + |
---|
107 | "--1729\r\n" + |
---|
108 | "Content-Type: message/rfc822\r\n" + |
---|
109 | "\r\n" + |
---|
110 | MIME_MULTIPART_EMBEDDED_MESSAGES_INNER_MAIL + |
---|
111 | "\r\n" + |
---|
112 | "--1729\r\n" + |
---|
113 | "Content-Type: multipart/mixed; boundary=4.66920160910299\r\n" + |
---|
114 | "\r\n" + |
---|
115 | MIME_MULTIPART_EMBEDDED_MESSAGES_INNER_MULTIPART_MIXED + "\r\n" + |
---|
116 | "--1729--\r\n" + |
---|
117 | "\r\n"; |
---|
118 | |
---|
119 | public static final String MD5_CONTENT = "Q2hlY2sgSW50ZWdyaXR5IQ=="; |
---|
120 | public static final String CONTENT_DESCRIPTION = "Blah blah blah"; |
---|
121 | public static final String CONTENT_ID = "<f470f68e0803061002n22bc4124he14015a4b6d6327f@mail.gmail.com>"; |
---|
122 | public static final Charset US_ASCII = CharsetUtil.US_ASCII; |
---|
123 | public static final Charset LATIN1 = CharsetUtil.ISO_8859_1; |
---|
124 | |
---|
125 | public static final String MIME_MULTIPART_EMBEDDED_MESSAGES = |
---|
126 | "From: Timothy Tayler <timothy@example.org>\r\n" + |
---|
127 | "To: Samual Smith <samual@example.org>\r\n" + |
---|
128 | "Date: Thu, 14 Feb 2008 12:00:00 +0000 (GMT)\r\n" + |
---|
129 | "Subject: A Multipart Email\r\n" + |
---|
130 | "Content-Type: multipart/mixed;boundary=1729\r\n" + |
---|
131 | "\r\n" + |
---|
132 | MIME_MULTIPART_EMBEDDED_MESSAGES_BODY; |
---|
133 | |
---|
134 | |
---|
135 | public static final String MULTIPART_WITH_CONTENT_LOCATION = |
---|
136 | "From: Timothy Tayler <timothy@example.org>\r\n" + |
---|
137 | "To: Samual Smith <samual@example.org>\r\n" + |
---|
138 | "Date: Thu, 14 Feb 2008 12:00:00 +0000 (GMT)\r\n" + |
---|
139 | "Subject: A Multipart Email With Content-Location\r\n" + |
---|
140 | "Content-Type: multipart/mixed;boundary=1729\r\n\r\n" + |
---|
141 | "Start with a preamble\r\n" + |
---|
142 | "\r\n--1729\r\n" + |
---|
143 | "Content-Type: application/xhtml+xml\r\n" + |
---|
144 | "Content-Location: relative/url\r\n\r\n" + |
---|
145 | "<!DOCTYPE html\r\n" + |
---|
146 | "PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\r\n" + |
---|
147 | "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n" + |
---|
148 | "<html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>\r\n" + |
---|
149 | "\r\n--1729\r\n" + |
---|
150 | "Content-Type: text/plain; charset=US-ASCII\r\n" + |
---|
151 | "Content-Location: http://www.example.org/absolute/rhubard.txt\r\n\r\n" + |
---|
152 | "Rhubarb!\r\n" + |
---|
153 | "\r\n--1729\r\n" + |
---|
154 | "Content-Type: text/html; charset=US-ASCII\r\n\r\n" + |
---|
155 | "<html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>\r\n" + |
---|
156 | "\r\n--1729\r\n" + |
---|
157 | "Content-Type: text/plain; charset=US-ASCII\r\n" + |
---|
158 | "Content-Location: (Some comment) \"http://www.example.org/absolute/comments/rhubard.txt\"(Another comment)\r\n\r\n" + |
---|
159 | "Rhubarb!\r\n" + |
---|
160 | "\r\n--1729\r\n" + |
---|
161 | "Content-Type: text/html; charset=US-ASCII\r\n" + |
---|
162 | "Content-Location:\"http://www.example.org/this/\r\n" + |
---|
163 | " is/a/very/long/url/split/\r\n" + |
---|
164 | " over/two/lines/\"\r\n\r\n" + |
---|
165 | "<html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>\r\n" + |
---|
166 | "\r\n--1729--\r\n" + |
---|
167 | "This is the epilogue\r\n"; |
---|
168 | |
---|
169 | public static final String MULTIPART_WITH_BINARY_ATTACHMENTS_HEADER = |
---|
170 | "Return-Path: <robertburrelldonkin@blueyonder.co.uk>\r\n" + |
---|
171 | "Received: (qmail 18554 invoked from network); 25 May 2008 14:38:53 -0000\r\n" + |
---|
172 | "Received: from unknown (HELO p3presmtp01-16.prod.phx3.secureserver.net)\r\n" + |
---|
173 | " ([208.109.80.165]) (envelope-sender <rdonkin-owner@locus.apache.org>) by\r\n" + |
---|
174 | " smtp20-01.prod.mesa1.secureserver.net (qmail-1.03) with SMTP for\r\n" + |
---|
175 | " <asf@xmlmapt.org>; 25 May 2008 14:38:53 -0000\r\n" + |
---|
176 | "Received: (qmail 9751 invoked from network); 25 May 2008 14:38:53 -0000\r\n" + |
---|
177 | "Received: from minotaur.apache.org ([140.211.11.9]) (envelope-sender\r\n" + |
---|
178 | " <rdonkin-owner@locus.apache.org>) by\r\n" + |
---|
179 | " p3presmtp01-16.prod.phx3.secureserver.net (qmail-ldap-1.03) with SMTP for\r\n" + |
---|
180 | " <asf@xmlmapt.org>; 25 May 2008 14:38:50 -0000\r\n" + |
---|
181 | "Received: (qmail 46768 invoked by uid 1289); 25 May 2008 14:38:46 -0000\r\n" + |
---|
182 | "Delivered-To: rdonkin@locus.apache.org\r\n" + |
---|
183 | "Received: (qmail 46763 invoked from network); 25 May 2008 14:38:46 -0000\r\n" + |
---|
184 | "Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by\r\n" + |
---|
185 | " minotaur.apache.org with SMTP; 25 May 2008 14:38:46 -0000\r\n" + |
---|
186 | "Received: (qmail 61275 invoked by uid 500); 25 May 2008 14:38:48 -0000\r\n" + |
---|
187 | "Delivered-To: apmail-rdonkin@apache.org\r\n" + |
---|
188 | "Delivered-To: rob@localhost\r\n" + |
---|
189 | "Delivered-To: rob@localhost\r\n" + |
---|
190 | "Received: (qmail 61272 invoked by uid 99); 25 May 2008 14:38:48 -0000\r\n" + |
---|
191 | "Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136)\r\n" + |
---|
192 | " by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 May 2008 07:38:48 -0700\r\n" + |
---|
193 | "X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS\r\n" + |
---|
194 | "X-Spam-Check-By: apache.org\r\n" + |
---|
195 | "Received-SPF: pass (athena.apache.org: domain of\r\n" + |
---|
196 | " robertburrelldonkin@blueyonder.co.uk designates 195.188.213.5 as permitted\r\n" + |
---|
197 | " sender)\r\n" + |
---|
198 | "Received: from [195.188.213.5] (HELO smtp-out2.blueyonder.co.uk)\r\n" + |
---|
199 | " (195.188.213.5) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 May 2008\r\n" + |
---|
200 | " 14:38:00 +0000\r\n" + |
---|
201 | "Received: from [172.23.170.140] (helo=anti-virus02-07) by\r\n" + |
---|
202 | " smtp-out2.blueyonder.co.uk with smtp (Exim 4.52) id 1K0HMV-00087e-HY for\r\n" + |
---|
203 | " rdonkin@apache.org; Sun, 25 May 2008 15:38:15 +0100\r\n" + |
---|
204 | "Received: from [82.38.65.6] (helo=[10.0.0.27]) by\r\n" + |
---|
205 | " asmtp-out5.blueyonder.co.uk with esmtpa (Exim 4.52) id 1K0HMU-0001A2-3q for\r\n" + |
---|
206 | " rdonkin@apache.org; Sun, 25 May 2008 15:38:14 +0100\r\n" + |
---|
207 | "Subject: This is an example of a multipart mixed email with image content\r\n" + |
---|
208 | "From: Robert Burrell Donkin <robertburrelldonkin@blueyonder.co.uk>\r\n" + |
---|
209 | "To: Robert Burrell Donkin <rdonkin@apache.org>\r\n" + |
---|
210 | "Content-Type: multipart/mixed; boundary=\"=-tIdGYVstQJghyEDATnJ+\"\r\n" + |
---|
211 | "Date: Sun, 25 May 2008 15:38:13 +0100\r\n" + |
---|
212 | "Message-Id: <1211726293.5772.10.camel@localhost>\r\n" + |
---|
213 | "Mime-Version: 1.0\r\n" + |
---|
214 | "X-Mailer: Evolution 2.12.3 \r\n" + |
---|
215 | "X-Virus-Checked: Checked by ClamAV on apache.org\r\n" + |
---|
216 | "X-Nonspam: None\r\n" + |
---|
217 | "X-fetched-from: mail.xmlmapt.org\r\n" + |
---|
218 | "X-Evolution-Source: imap://rob@thebes/\r\n" + |
---|
219 | "\r\n"; |
---|
220 | |
---|
221 | public static final String MULTIPART_WITH_BINARY_ATTACHMENTS_BODY = "--=-tIdGYVstQJghyEDATnJ+\r\n" + |
---|
222 | "Content-Type: text/plain\r\n" + |
---|
223 | "Content-Transfer-Encoding: 7bit\r\n" + |
---|
224 | "\r\n" + |
---|
225 | "Licensed to the Apache Software Foundation (ASF) under one\r\n" + |
---|
226 | "or more contributor license agreements. See the NOTICE file\r\n" + |
---|
227 | "distributed with this work for additional information\r\n" + |
---|
228 | "regarding copyright ownership. The ASF licenses this file\r\n" + |
---|
229 | "to you under the Apache License, Version 2.0 (the\r\n" + |
---|
230 | "\"License\"); you may not use this file except in compliance\r\n" + |
---|
231 | "with the License. You may obtain a copy of the License at\r\n" + |
---|
232 | "\r\n" + |
---|
233 | " http://www.apache.org/licenses/LICENSE-2.0\r\n" + |
---|
234 | " \r\n" + |
---|
235 | "Unless required by applicable law or agreed to in writing,\r\n" + |
---|
236 | "software distributed under the License is distributed on an\r\n" + |
---|
237 | "\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\n" + |
---|
238 | "KIND, either express or implied. See the License for the\r\n" + |
---|
239 | "specific language governing permissions and limitations\r\n" + |
---|
240 | "under the License.\r\n" + |
---|
241 | " \r\n" + |
---|
242 | "\r\n" + |
---|
243 | "--=-tIdGYVstQJghyEDATnJ+\r\n" + |
---|
244 | "Content-Disposition: attachment; filename=blob.png;\r\n modification-date=\"Sun, 21 Jun 2008 15:32:18 +0000\"; " + |
---|
245 | "creation-date=\"Sat, 20 Jun 2008 10:15:09 +0000\"; read-date=\"Mon, 22 Jun 2008 12:08:56 +0000\";size=10234;\r\n" + |
---|
246 | "Content-Type: image/png; name=blob.png\r\n" + |
---|
247 | "Content-Transfer-Encoding: base64\r\n" + |
---|
248 | "\r\n" + |
---|
249 | "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAL\r\n" + |
---|
250 | "EwAACxMBAJqcGAAAAAd0SU1FB9gFGQ4iJ99ufcYAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRo\r\n" + |
---|
251 | "IEdJTVBXgQ4XAAAA0ElEQVQY02XMwUrDQBhF4XsnkyYhjWJaCloEN77/a/gERVwJLQiiNjYmbTqZ\r\n" + |
---|
252 | "/7qIG/VsPziMTw+23Wj/ovZdMQJgViCvWNVusfa23djuUf2nugbnI2RynkWF5a2Fwdvrs7q9vhqE\r\n" + |
---|
253 | "E2QAEIO6BhZBerUf6luMw49NyTR0OLw5kJD9sqk4Ipwc6GAREv5n5piXTDOQfy1JMSs8ZgXKq2kF\r\n" + |
---|
254 | "iwDgEriEecnLlefFEmGAIvqD4ggJJNMM85qLtXfX9xYGuEQ+4/kIi0g88zlXd66++QaQDG5GPZyp\r\n" + |
---|
255 | "rQAAAABJRU5ErkJggg==\r\n" + |
---|
256 | "\r\n" + |
---|
257 | "--=-tIdGYVstQJghyEDATnJ+\r\n" + |
---|
258 | "Content-Disposition: attachment; filename=blob.png\r\n" + |
---|
259 | "Content-Type: image/png; name=blob.png\r\n" + |
---|
260 | "Content-Transfer-Encoding: base64\r\n" + |
---|
261 | "\r\n" + |
---|
262 | "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAL\r\n" + |
---|
263 | "EwAACxMBAJqcGAAAAAd0SU1FB9gFGQ4iJ99ufcYAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRo\r\n" + |
---|
264 | "IEdJTVBXgQ4XAAAA0ElEQVQY02XMwUrDQBhF4XsnkyYhjWJaCloEN77/a/gERVwJLQiiNjYmbTqZ\r\n" + |
---|
265 | "/7qIG/VsPziMTw+23Wj/ovZdMQJgViCvWNVusfa23djuUf2nugbnI2RynkWF5a2Fwdvrs7q9vhqE\r\n" + |
---|
266 | "E2QAEIO6BhZBerUf6luMw49NyTR0OLw5kJD9sqk4Ipwc6GAREv5n5piXTDOQfy1JMSs8ZgXKq2kF\r\n" + |
---|
267 | "iwDgEriEecnLlefFEmGAIvqD4ggJJNMM85qLtXfX9xYGuEQ+4/kIi0g88zlXd66++QaQDG5GPZyp\r\n" + |
---|
268 | "rQAAAABJRU5ErkJggg==\r\n" + |
---|
269 | "\r\n" + |
---|
270 | "--=-tIdGYVstQJghyEDATnJ+\r\n" + |
---|
271 | "Content-Disposition: attachment; filename=rhubarb.txt\r\n" + |
---|
272 | "Content-Type: text/plain; name=rhubarb.txt; charset=us-ascii\r\n" + |
---|
273 | "Content-Language: en, en-US, en-CA\r\n" + |
---|
274 | "Content-Transfer-Encoding: quoted-printable\r\n" + |
---|
275 | "\r\n" + |
---|
276 | "Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhu=\r\n" + |
---|
277 | "barb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubar=\r\n" + |
---|
278 | "b Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb R=\r\n" + |
---|
279 | "hubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhub=\r\n" + |
---|
280 | "arb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb=\r\n" + |
---|
281 | " Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rh=\r\n" + |
---|
282 | "ubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhuba=\r\n" + |
---|
283 | "rb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb =\r\n" + |
---|
284 | "Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhu=\r\n" + |
---|
285 | "barb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubar=\r\n" + |
---|
286 | "b Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb R=\r\n" + |
---|
287 | "hubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhub=\r\n" + |
---|
288 | "arb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb=\r\n" + |
---|
289 | " Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rh=\r\n" + |
---|
290 | "ubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhuba=\r\n" + |
---|
291 | "rb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb =\r\n" + |
---|
292 | "Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhu=\r\n" + |
---|
293 | "barb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubar=\r\n" + |
---|
294 | "b Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb R=\r\n" + |
---|
295 | "hubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhub=\r\n" + |
---|
296 | "arb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb=\r\n" + |
---|
297 | " Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rh=\r\n" + |
---|
298 | "ubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhuba=\r\n" + |
---|
299 | "rb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb =\r\n" + |
---|
300 | "Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhu=\r\n" + |
---|
301 | "barb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubar=\r\n" + |
---|
302 | "b Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb R=\r\n" + |
---|
303 | "hubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhub=\r\n" + |
---|
304 | "arb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb=\r\n" + |
---|
305 | " Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rh=\r\n" + |
---|
306 | "ubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhuba=\r\n" + |
---|
307 | "rb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb =\r\n" + |
---|
308 | "Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhu=\r\n" + |
---|
309 | "barb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubar=\r\n" + |
---|
310 | "b Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb R=\r\n" + |
---|
311 | "hubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhub=\r\n" + |
---|
312 | "arb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb=\r\n" + |
---|
313 | " Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rh=\r\n" + |
---|
314 | "ubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhuba=\r\n" + |
---|
315 | "rb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb =\r\n" + |
---|
316 | "Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb Rhubarb\r\n" + |
---|
317 | "\r\n" + |
---|
318 | "--=-tIdGYVstQJghyEDATnJ+--\r\n"; |
---|
319 | |
---|
320 | public static final String MULTIPART_WITH_BINARY_ATTACHMENTS = MULTIPART_WITH_BINARY_ATTACHMENTS_HEADER + |
---|
321 | "\r\n" + MULTIPART_WITH_BINARY_ATTACHMENTS_BODY; |
---|
322 | |
---|
323 | public static final String MULTIPART_WITH_BINARY_ATTACHMENTS_NOPREAMBLE = MULTIPART_WITH_BINARY_ATTACHMENTS_HEADER + |
---|
324 | MULTIPART_WITH_BINARY_ATTACHMENTS_BODY; |
---|
325 | |
---|
326 | public static final String MULTIPART_WITH_BINARY_ATTACHMENTS_PREAMBLE_EPILOGUE = MULTIPART_WITH_BINARY_ATTACHMENTS_HEADER + |
---|
327 | "This is a preamble\r\n" + |
---|
328 | "With 2 lines\r\n" + MULTIPART_WITH_BINARY_ATTACHMENTS_BODY + |
---|
329 | "This is an epilogue\r\n" + |
---|
330 | "With 2 lines\r\n"; |
---|
331 | |
---|
332 | public static final String ONE_PART_MIME_ASCII_BODY = "A single part MIME mail.\r\n"; |
---|
333 | |
---|
334 | public static final String RFC822_SIMPLE_BODY = "This is a very simple email.\r\n"; |
---|
335 | |
---|
336 | public static final String ONE_PART_MIME_8859_BODY = "M\u00F6nchengladbach\r\n"; |
---|
337 | |
---|
338 | public static final String ONE_PART_MIME_BASE64_LATIN1_BODY = "Hello Mo\u00F6nchengladbach\r\n"; |
---|
339 | |
---|
340 | public static final String ONE_PART_MIME_QUOTED_PRINTABLE_ASCII_BODY = "Sonnet LXXXI By William Shakespeare\r\n" + |
---|
341 | "Or I shall live your epitaph to make,\r\n" + |
---|
342 | "Or you survive when I in earth am rotten;\r\n" + |
---|
343 | "From hence your memory death cannot take,\r\n" + |
---|
344 | "Although in me each part will be forgotten.\r\n" + |
---|
345 | "Your name from hence immortal life shall have,\r\n" + |
---|
346 | "Though I, once gone, to all the world must die:\r\n" + |
---|
347 | "The earth can yield me but a common grave,\r\n" + |
---|
348 | "When you entombed in men's eyes shall lie.\r\n" + |
---|
349 | "Your monument shall be my gentle verse,\r\n" + |
---|
350 | "Which eyes not yet created shall o'er-read;\r\n" + |
---|
351 | "And tongues to be, your being shall rehearse,\r\n" + |
---|
352 | "When all the breathers of this world are dead;\r\n" + |
---|
353 | " You still shall live,--such virtue hath my pen,--\r\n" + |
---|
354 | " Where breath most breathes, even in the mouths of men.\r\n"; |
---|
355 | |
---|
356 | private static final byte[] ONE_PART_MIME_BASE64_LATIN1_ENCODED = EncodeUtils.toBase64(latin1(ONE_PART_MIME_BASE64_LATIN1_BODY)); |
---|
357 | |
---|
358 | public static final String ONE_PART_MIME_BASE64_ASCII_BODY = "Hello, World!\r\n"; |
---|
359 | |
---|
360 | public static final String ONE_PART_MIME_WITH_CONTENT_DISPOSITION_PARAMETERS = |
---|
361 | "Message-ID: <f470f68e0803061002n22bc4124he14015a4b6d6327f@mail.gmail.com>\r\n" + |
---|
362 | "Date: Thu, 6 Mar 2008 18:02:03 +0000\r\n" + |
---|
363 | "From: \"Robert Burrell Donkin\" <robertburrelldonkin@gmail.com>\r\n" + |
---|
364 | "To: \"James Developers List\" <server-dev@james.apache.org>\r\n" + |
---|
365 | "Subject: [Mime4J] getReader\r\n" + |
---|
366 | "MIME-Version: 1.0\r\n" + |
---|
367 | "Content-Type: text/plain; charset=US-ASCII\r\n" + |
---|
368 | "Content-Transfer-Encoding: 7bit\r\n" + |
---|
369 | "Content-Disposition: inline; foo=bar; one=1; param=value;\r\n" + |
---|
370 | "Content-MD5: " + MD5_CONTENT + "\r\n" + |
---|
371 | "Delivered-To: robertburrelldonkin@gmail.com\r\n" + |
---|
372 | "\r\n" + |
---|
373 | ONE_PART_MIME_ASCII_BODY; |
---|
374 | |
---|
375 | private static final byte[] ONE_PART_MIME_BASE64_ASCII_ENCODED = EncodeUtils.toBase64(ascii(ONE_PART_MIME_BASE64_ASCII_BODY)); |
---|
376 | |
---|
377 | public static final String ONE_PART_MIME_ASCII = "Received: by 10.114.126.16 with HTTP; Thu, 6 Mar 2008 10:02:03 -0800 (PST)\r\n" + |
---|
378 | "Message-ID: <f470f68e0803061002n22bc4124he14015a4b6d6327f@mail.gmail.com>\r\n" + |
---|
379 | "Date: Thu, 6 Mar 2008 18:02:03 +0000\r\n" + |
---|
380 | "From: \"Robert Burrell Donkin\" <robertburrelldonkin@gmail.com>\r\n" + |
---|
381 | "To: \"James Developers List\" <server-dev@james.apache.org>\r\n" + |
---|
382 | "Subject: [Mime4J] getReader\r\n" + |
---|
383 | "MIME-Version: 1.0\r\n" + |
---|
384 | "Content-Type: text/plain; charset=US-ASCII\r\n" + |
---|
385 | "Content-Transfer-Encoding: 7bit\r\n" + |
---|
386 | "Content-Disposition: inline\r\n" + |
---|
387 | "Delivered-To: robertburrelldonkin@gmail.com\r\n" + |
---|
388 | "\r\n" + |
---|
389 | ONE_PART_MIME_ASCII_BODY; |
---|
390 | |
---|
391 | public static final String ONE_PART_MIME_ASCII_COMMENT_IN_MIME_VERSION = "Received: by 10.114.126.16 with HTTP; Thu, 6 Mar 2008 10:02:03 -0800 (PST)\r\n" + |
---|
392 | "Message-ID: <f470f68e0803061002n22bc4124he14015a4b6d6327f@mail.gmail.com>\r\n" + |
---|
393 | "Date: Thu, 6 Mar 2008 18:02:03 +0000\r\n" + |
---|
394 | "From: \"Robert Burrell Donkin\" <robertburrelldonkin@gmail.com>\r\n" + |
---|
395 | "To: \"James Developers List\" <server-dev@james.apache.org>\r\n" + |
---|
396 | "Subject: [Mime4J] getReader\r\n" + |
---|
397 | "MIME-Version: 2.(This is a comment)4\r\n" + |
---|
398 | "Content-Type: text/plain; charset=US-ASCII\r\n" + |
---|
399 | "Content-Transfer-Encoding: 7bit\r\n" + |
---|
400 | "Content-Disposition: inline\r\n" + |
---|
401 | "Delivered-To: robertburrelldonkin@gmail.com\r\n" + |
---|
402 | "\r\n" + ONE_PART_MIME_ASCII_BODY; |
---|
403 | |
---|
404 | public static final String ONE_PART_MIME_ASCII_MIME_VERSION_SPANS_TWO_LINES = "Received: by 10.114.126.16 with HTTP; Thu, 6 Mar 2008 10:02:03 -0800 (PST)\r\n" + |
---|
405 | "Message-ID: <f470f68e0803061002n22bc4124he14015a4b6d6327f@mail.gmail.com>\r\n" + |
---|
406 | "Date: Thu, 6 Mar 2008 18:02:03 +0000\r\n" + |
---|
407 | "From: \"Robert Burrell Donkin\" <robertburrelldonkin@gmail.com>\r\n" + |
---|
408 | "To: \"James Developers List\" <server-dev@james.apache.org>\r\n" + |
---|
409 | "Subject: [Mime4J] getReader\r\n" + |
---|
410 | "MIME-Version: 4. \r\n" + |
---|
411 | " 1\r\n" + |
---|
412 | "Content-Type: text/plain; charset=US-ASCII\r\n" + |
---|
413 | "Content-Transfer-Encoding: 7bit\r\n" + |
---|
414 | "Content-Disposition: inline\r\n" + |
---|
415 | "Delivered-To: robertburrelldonkin@gmail.com\r\n" + |
---|
416 | "\r\n" + ONE_PART_MIME_ASCII_BODY; |
---|
417 | |
---|
418 | public static final String INNER_MAIL = "From: Timothy Tayler <tim@example.org>\r\n" + |
---|
419 | "To: Joshua Tetley <joshua@example.org>\r\n" + |
---|
420 | "Date: Tue, 12 Feb 2008 17:34:09 +0000 (GMT)\r\n" + |
---|
421 | "Subject: Multipart Without RFC822 Part\r\n" + |
---|
422 | "Content-Type: multipart/mixed;boundary=42\r\n\r\n" + |
---|
423 | "--42\r\n" + |
---|
424 | "Content-Type:text/plain; charset=US-ASCII\r\n\r\n" + |
---|
425 | "First part of this mail\r\n" + |
---|
426 | "--42\r\n" + |
---|
427 | "Content-Type:text/plain; charset=US-ASCII\r\n\r\n" + |
---|
428 | "Second part of this mail\r\n" + |
---|
429 | "--42--\r\n"; |
---|
430 | |
---|
431 | public static final String MAIL_WITH_RFC822_PART = "MIME-Version: 1.0\r\n" + |
---|
432 | "From: Timothy Tayler <tim@example.org>\r\n" + |
---|
433 | "To: Joshua Tetley <joshua@example.org>\r\n" + |
---|
434 | "Date: Tue, 12 Feb 2008 17:34:09 +0000 (GMT)\r\n" + |
---|
435 | "Subject: Multipart With RFC822 Part\r\n" + |
---|
436 | "Content-Type: multipart/mixed;boundary=1729\r\n\r\n" + |
---|
437 | "A short premable\r\n" + |
---|
438 | "--1729\r\n\r\n" + |
---|
439 | "First part has no headers\r\n" + |
---|
440 | "--1729\r\n" + |
---|
441 | "Content-Type: text/plain; charset=US-ASCII\r\n\r\n" + |
---|
442 | "Second part is plain text\r\n" + |
---|
443 | "--1729\r\n" + |
---|
444 | "Content-Type: message/rfc822\r\n\r\n" + |
---|
445 | INNER_MAIL + |
---|
446 | "--1729\r\n" + |
---|
447 | "Content-Type: text/plain; charset=US-ASCII\r\n\r\n" + |
---|
448 | "Last part is plain text\r\n" + |
---|
449 | "--1729--\r\n" + |
---|
450 | "The End"; |
---|
451 | |
---|
452 | public static final String ONE_PART_MIME_8859 = "Received: by 10.114.126.16 with HTTP; Thu, 6 Mar 2008 10:02:03 -0800 (PST)\r\n" + |
---|
453 | "Message-ID: <f470f68e0803061002n22bc4124he14015a4b6d6327f@mail.gmail.com>\r\n" + |
---|
454 | "Date: Thu, 6 Mar 2008 18:02:03 +0000\r\n" + |
---|
455 | "From: \"Robert Burrell Donkin\" <robertburrelldonkin@gmail.com>\r\n" + |
---|
456 | "To: \"James Developers List\" <server-dev@james.apache.org>\r\n" + |
---|
457 | "Subject: [Mime4J] getReader\r\n" + |
---|
458 | "MIME-Version: 1.0\r\n" + |
---|
459 | "Content-Type: text/plain; charset=ISO-8859-1\r\n" + |
---|
460 | "Content-Transfer-Encoding: 8bit\r\n" + |
---|
461 | "Content-Disposition: inline\r\n" + |
---|
462 | "Content-ID: " + CONTENT_ID + "\r\n" + |
---|
463 | "Content-Description: " + CONTENT_DESCRIPTION + "\r\n" + |
---|
464 | "Delivered-To: robertburrelldonkin@gmail.com\r\n" + |
---|
465 | "\r\n" + |
---|
466 | ONE_PART_MIME_8859_BODY; |
---|
467 | |
---|
468 | public static final String ONE_PART_MIME_BASE64_ASCII_HEADERS = "Received: by 10.114.126.16 with HTTP; Thu, 6 Mar 2008 10:02:03 -0800 (PST)\r\n" + |
---|
469 | "Message-ID: <f470f68e0803061002n22bc4124he14015a4b6d6327f@mail.gmail.com>\r\n" + |
---|
470 | "Date: Thu, 6 Mar 2008 18:02:03 +0000\r\n" + |
---|
471 | "From: \"Robert Burrell Donkin\" <robertburrelldonkin@gmail.com>\r\n" + |
---|
472 | "To: \"James Developers List\" <server-dev@james.apache.org>\r\n" + |
---|
473 | "Subject: [Mime4J] getReader\r\n" + |
---|
474 | "MIME-Version: 1.0\r\n" + |
---|
475 | "Content-Type: text/plain; charset=US-ASCII\r\n" + |
---|
476 | "Content-Transfer-Encoding: base64\r\n" + |
---|
477 | "Content-Disposition: inline\r\n" + |
---|
478 | "Delivered-To: robertburrelldonkin@gmail.com\r\n" + |
---|
479 | "\r\n"; |
---|
480 | |
---|
481 | public static final String ONE_PART_MIME_BASE64_LATIN1_HEADERS = "Received: by 10.114.126.16 with HTTP; Thu, 6 Mar 2008 10:02:03 -0800 (PST)\r\n" + |
---|
482 | "Message-ID: <f470f68e0803061002n22bc4124he14015a4b6d6327f@mail.gmail.com>\r\n" + |
---|
483 | "Date: Thu, 6 Mar 2008 18:02:03 +0000\r\n" + |
---|
484 | "From: \"Robert Burrell Donkin\" <robertburrelldonkin@gmail.com>\r\n" + |
---|
485 | "To: \"James Developers List\" <server-dev@james.apache.org>\r\n" + |
---|
486 | "Subject: [Mime4J] getReader\r\n" + |
---|
487 | "MIME-Version: 1.0\r\n" + |
---|
488 | "Content-Type: text/plain; charset=ISO-8859-1\r\n" + |
---|
489 | "Content-Transfer-Encoding: base64\r\n" + |
---|
490 | "Content-Disposition: inline\r\n" + |
---|
491 | "Delivered-To: robertburrelldonkin@gmail.com\r\n" + |
---|
492 | "\r\n"; |
---|
493 | |
---|
494 | public static final String ONE_PART_MIME_QUOTED_PRINTABLE_ASCII = "Received: by 10.114.126.16 with HTTP; Thu, 6 Mar 2008 10:02:03 -0800 (PST)\r\n" + |
---|
495 | "Message-ID: <f470f68e0803061002n22bc4124he14015a4b6d6327f@mail.gmail.com>\r\n" + |
---|
496 | "Date: Thu, 6 Mar 2008 18:02:03 +0000\r\n" + |
---|
497 | "From: \"Robert Burrell Donkin\" <robertburrelldonkin@gmail.com>\r\n" + |
---|
498 | "To: \"James Developers List\" <server-dev@james.apache.org>\r\n" + |
---|
499 | "Subject: [Mime4J] getReader\r\n" + |
---|
500 | "MIME-Version: 1.0\r\n" + |
---|
501 | "Content-Type: text/plain; charset=US-ASCII\r\n" + |
---|
502 | "Content-Transfer-Encoding: Quoted-Printable\r\n" + |
---|
503 | "Content-Disposition: inline\r\n" + |
---|
504 | "Delivered-To: robertburrelldonkin@gmail.com\r\n" + |
---|
505 | "\r\n" + breakLines(ONE_PART_MIME_QUOTED_PRINTABLE_ASCII_BODY.replaceAll("\r\n", "=0D=0A")); |
---|
506 | |
---|
507 | |
---|
508 | public static final String RFC_SIMPLE = |
---|
509 | "From: Timothy Tayler <timothy@example.org>\r\n" + |
---|
510 | "To: Samual Smith <samual@example.org>\r\n" + |
---|
511 | "Date: Thu, 14 Feb 2008 12:00:00 +0000 (GMT)\r\n" + |
---|
512 | "Subject: A Simple Email\r\n" + |
---|
513 | "\r\n" + |
---|
514 | RFC822_SIMPLE_BODY; |
---|
515 | |
---|
516 | public static final String MIME_RFC822_SIMPLE = |
---|
517 | "From: Samual Smith <sam@example.org>\r\n" + |
---|
518 | "To: Joshua Tetley <josh@example.org>\r\n" + |
---|
519 | "Date: Thu, 14 Feb 2008 12:30:00 +0000 (GMT)\r\n" + |
---|
520 | "Subject: FW: A Simple Email\r\n" + |
---|
521 | "MIME-Version: 1.0\r\n" + |
---|
522 | "Content-Type: message/rfc822\r\n" + |
---|
523 | "\r\n" + RFC_SIMPLE; |
---|
524 | |
---|
525 | public static final String MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_7BIT = "Sonnet XXXIII By William Shakespeare\r\n" + |
---|
526 | "\r\n" + |
---|
527 | "Full many a glorious morning have I seen\r\n" + |
---|
528 | "Flatter the mountain tops with sovereign eye,\r\n" + |
---|
529 | "Kissing with golden face the meadows green,\r\n" + |
---|
530 | "Gilding pale streams with heavenly alchemy;\r\n" + |
---|
531 | "Anon permit the basest clouds to ride\r\n" + |
---|
532 | "With ugly rack on his celestial face,\r\n" + |
---|
533 | "And from the forlorn world his visage hide,\r\n" + |
---|
534 | "Stealing unseen to west with this disgrace:\r\n" + |
---|
535 | "Even so my sun one early morn did shine,\r\n" + |
---|
536 | "With all triumphant splendour on my brow;\r\n" + |
---|
537 | "But out! alack! he was but one hour mine,\r\n" + |
---|
538 | "The region cloud hath mask'd him from me now.\r\n" + |
---|
539 | " Yet him for this my love no whit disdaineth;\r\n" + |
---|
540 | " Suns of the world may stain when heaven's sun staineth.\r\n"; |
---|
541 | |
---|
542 | public static final String MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_QUOTED_PRINTABLE = "Sonnet XXXV By William Shakespeare\r\n" + |
---|
543 | "\r\n" + |
---|
544 | "No more be griev'd at that which thou hast done:\r\n" + |
---|
545 | "Roses have thorns, and silver fountains mud:\r\n" + |
---|
546 | "Clouds and eclipses stain both moon and sun,\r\n" + |
---|
547 | "And loathsome canker lives in sweetest bud.\r\n" + |
---|
548 | "All men make faults, and even I in this,\r\n" + |
---|
549 | "Authorizing thy trespass with compare,\r\n" + |
---|
550 | "Myself corrupting, salving thy amiss,\r\n" + |
---|
551 | "Excusing thy sins more than thy sins are;\r\n" + |
---|
552 | "For to thy sensual fault I bring in sense,--\r\n" + |
---|
553 | "Thy adverse party is thy advocate,--\r\n" + |
---|
554 | "And 'gainst myself a lawful plea commence:\r\n" + |
---|
555 | "Such civil war is in my love and hate,\r\n" + |
---|
556 | " That I an accessary needs must be,\r\n" + |
---|
557 | " To that sweet thief which sourly robs from me.\r\n"; |
---|
558 | |
---|
559 | public static final String MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_BASE64 = "Sonnet XXXVIII By William Shakespeare\r\n" + |
---|
560 | "\r\n" + |
---|
561 | "How can my muse want subject to invent,\r\n" + |
---|
562 | "While thou dost breathe, that pour'st into my verse\r\n" + |
---|
563 | "Thine own sweet argument, too excellent\r\n" + |
---|
564 | "For every vulgar paper to rehearse?\r\n" + |
---|
565 | "O! give thy self the thanks, if aught in me\r\n" + |
---|
566 | "Worthy perusal stand against thy sight;\r\n" + |
---|
567 | "For who's so dumb that cannot write to thee,\r\n" + |
---|
568 | "When thou thy self dost give invention light?\r\n" + |
---|
569 | "Be thou the tenth Muse, ten times more in worth\r\n" + |
---|
570 | "Than those old nine which rhymers invocate;\r\n" + |
---|
571 | "And he that calls on thee, let him bring forth\r\n" + |
---|
572 | "Eternal numbers to outlive long date.\r\n" + |
---|
573 | " If my slight muse do please these curious days,\r\n" + |
---|
574 | " The pain be mine, but thine shall be the praise.\r\n"; |
---|
575 | |
---|
576 | public static final String MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_ONE = |
---|
577 | "From: Timothy Tayler <timothy@example.org>\r\n" + |
---|
578 | "To: Samual Smith <samual@example.org>\r\n" + |
---|
579 | "Date: Thu, 14 Feb 2008 12:00:00 +0000 (GMT)\r\n" + |
---|
580 | "Subject: A Multipart Email\r\n" + |
---|
581 | "Content-Type: multipart/mixed;boundary=1729\r\n" + |
---|
582 | "\r\n" + |
---|
583 | "Start with a preamble\r\n" + |
---|
584 | "\r\n" + |
---|
585 | "--1729\r\n" + |
---|
586 | "Content-Type: text/plain; charset=US-ASCII\r\n" + |
---|
587 | "Content-Transfer-Encoding: 7bit\r\n\r\n"; |
---|
588 | |
---|
589 | public static final String MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_TWO = |
---|
590 | "\r\n--1729\r\n" + |
---|
591 | "Content-Type: text/plain; charset=US-ASCII\r\n" + |
---|
592 | "Content-Transfer-Encoding: Quoted-Printable\r\n\r\n"; |
---|
593 | |
---|
594 | public static final String MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_THREE = |
---|
595 | "\r\n--1729\r\n" + |
---|
596 | "Content-Type: text/plain; charset=US-ASCII\r\n" + |
---|
597 | "Content-Transfer-Encoding: base64\r\n\r\n"; |
---|
598 | |
---|
599 | public static final String MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_END = |
---|
600 | "\r\n--1729--\r\n"; |
---|
601 | |
---|
602 | public static final String MIME_MULTIPART_ALTERNATIVE = |
---|
603 | "From: Timothy Tayler <timothy@example.org>\r\n" + |
---|
604 | "To: Samual Smith <samual@example.org>\r\n" + |
---|
605 | "Date: Thu, 14 Feb 2008 12:00:00 +0000 (GMT)\r\n" + |
---|
606 | "Subject: A Multipart Email\r\n" + |
---|
607 | "Content-Type: multipart/alternative;boundary=1729\r\n\r\n" + |
---|
608 | "Start with a preamble\r\n" + |
---|
609 | "\r\n--1729\r\n" + |
---|
610 | "Content-Type: application/xhtml+xml\r\n\r\n" + |
---|
611 | "<!DOCTYPE html\r\n" + |
---|
612 | "PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\r\n" + |
---|
613 | "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n" + |
---|
614 | "<html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>\r\n" + |
---|
615 | "\r\n--1729\r\n" + |
---|
616 | "Content-Type: text/plain; charset=US-ASCII\r\n\r\n" + |
---|
617 | "Rhubarb!\r\n" + |
---|
618 | "\r\n--1729\r\n" + |
---|
619 | "Content-Type: text/html; charset=US-ASCII\r\n\r\n" + |
---|
620 | "<html><head><title>Rhubarb</title></head><body>Rhubarb!</body></html>\r\n" + |
---|
621 | "\r\n--1729--\r\n" + |
---|
622 | "This is the epilogue\r\n"; |
---|
623 | |
---|
624 | |
---|
625 | private static final byte[][] MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_BYTE_ARRAYS = { |
---|
626 | ascii(MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_ONE), |
---|
627 | ascii(MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_7BIT), |
---|
628 | ascii(MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_TWO), |
---|
629 | ascii(breakLines(MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_QUOTED_PRINTABLE.replaceAll("\r\n", "=0D=0A"))), |
---|
630 | ascii(MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_THREE), |
---|
631 | EncodeUtils.toBase64(ascii(MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_BASE64)), |
---|
632 | ascii(MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_END), |
---|
633 | }; |
---|
634 | |
---|
635 | public static final byte[] MIME_RFC822_SIMPLE_BYTES = ascii(MIME_RFC822_SIMPLE); |
---|
636 | public static final byte[] MULTIPART_WITH_CONTENT_LOCATION_BYTES = ascii(MULTIPART_WITH_CONTENT_LOCATION); |
---|
637 | public static final byte[] ONE_PART_MIME_WITH_CONTENT_DISPOSITION_PARAMETERS_BYTES = ascii(ONE_PART_MIME_WITH_CONTENT_DISPOSITION_PARAMETERS); |
---|
638 | public static final byte[] MIME_MULTIPART_ALTERNATIVE_BYTES = ascii(MIME_MULTIPART_ALTERNATIVE); |
---|
639 | public static final byte[] MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_BYTES = join(MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_BYTE_ARRAYS); |
---|
640 | public static final byte[] ONE_PART_MIME_QUOTED_PRINTABLE_ASCII_BYTES = ascii(ONE_PART_MIME_QUOTED_PRINTABLE_ASCII); |
---|
641 | public static final byte[] ONE_PART_MIME_BASE64_LATIN1_UPPERCASE_BYTES = join(ascii(ONE_PART_MIME_BASE64_LATIN1_HEADERS.toUpperCase(Locale.UK)), ONE_PART_MIME_BASE64_LATIN1_ENCODED); |
---|
642 | public static final byte[] ONE_PART_MIME_BASE64_LATIN1_BYTES = join(ascii(ONE_PART_MIME_BASE64_LATIN1_HEADERS), ONE_PART_MIME_BASE64_LATIN1_ENCODED); |
---|
643 | public static final byte[] ONE_PART_MIME_BASE64_ASCII_BYTES = join(ascii(ONE_PART_MIME_BASE64_ASCII_HEADERS), ONE_PART_MIME_BASE64_ASCII_ENCODED); |
---|
644 | public static final byte[] RFC822_SIMPLE_BYTES = US_ASCII.encode(RFC_SIMPLE).array(); |
---|
645 | public static final byte[] ONE_PART_MIME_ASCII_BYTES = US_ASCII.encode(ONE_PART_MIME_ASCII).array(); |
---|
646 | public static final byte[] ONE_PART_MIME_8859_BYTES = LATIN1.encode(ONE_PART_MIME_8859).array(); |
---|
647 | public static final byte[] MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES = US_ASCII.encode(MULTIPART_WITH_BINARY_ATTACHMENTS).array(); |
---|
648 | public static final byte[] MULTIPART_WITH_BINARY_ATTACHMENTS_NOPREAMBLE_BYTES = US_ASCII.encode(MULTIPART_WITH_BINARY_ATTACHMENTS_NOPREAMBLE).array(); |
---|
649 | public static final byte[] MULTIPART_WITH_BINARY_ATTACHMENTS_PREAMBLE_EPILOGUE_BYTES = US_ASCII.encode(MULTIPART_WITH_BINARY_ATTACHMENTS_PREAMBLE_EPILOGUE).array(); |
---|
650 | public static final byte[] ONE_PART_MIME_ASCII_COMMENT_IN_MIME_VERSION_BYTES = US_ASCII.encode(ONE_PART_MIME_ASCII_COMMENT_IN_MIME_VERSION).array(); |
---|
651 | public static final byte[] ONE_PART_MIME_ASCII_MIME_VERSION_SPANS_TWO_LINES_BYTES = US_ASCII.encode(ONE_PART_MIME_ASCII_MIME_VERSION_SPANS_TWO_LINES).array(); |
---|
652 | public static final byte[] MAIL_WITH_RFC822_PART_BYTES = ascii(MAIL_WITH_RFC822_PART); |
---|
653 | public static final byte[] MIME_MULTIPART_EMBEDDED_MESSAGES_BYTES = ascii(MIME_MULTIPART_EMBEDDED_MESSAGES); |
---|
654 | |
---|
655 | public static final byte[] ascii(String text) { |
---|
656 | |
---|
657 | return US_ASCII.encode(text).array(); |
---|
658 | } |
---|
659 | |
---|
660 | public static final byte[] latin1(String text) { |
---|
661 | |
---|
662 | return LATIN1.encode(text).array(); |
---|
663 | } |
---|
664 | |
---|
665 | public static final byte[] join(byte[] one, byte[] two) { |
---|
666 | byte[] results = new byte[one.length + two.length]; |
---|
667 | System.arraycopy(one, 0, results, 0, one.length); |
---|
668 | System.arraycopy(two, 0, results, one.length, two.length); |
---|
669 | return results; |
---|
670 | } |
---|
671 | |
---|
672 | public static final byte[] join(byte[][] byteArrays) { |
---|
673 | int length = 0; |
---|
674 | for (byte[] bytes : byteArrays) { |
---|
675 | length += bytes.length; |
---|
676 | } |
---|
677 | byte[] results = new byte[length]; |
---|
678 | int count = 0; |
---|
679 | for (byte[] bytes : byteArrays) { |
---|
680 | System.arraycopy(bytes, 0, results, count, bytes.length); |
---|
681 | count += bytes.length; |
---|
682 | } |
---|
683 | return results; |
---|
684 | } |
---|
685 | |
---|
686 | public static String breakLines(String original) { |
---|
687 | StringBuilder buffer = new StringBuilder(original); |
---|
688 | int count = 76; |
---|
689 | while(count < buffer.length()) { |
---|
690 | if (buffer.charAt(count) == '=') { |
---|
691 | count = count - 1; |
---|
692 | } else if (buffer.charAt(count-1) == '=') { |
---|
693 | count = count - 4; |
---|
694 | } else if (buffer.charAt(count-2) == '=') { |
---|
695 | count = count - 3; |
---|
696 | } |
---|
697 | buffer.insert(count, '\n'); |
---|
698 | buffer.insert(count, '\r'); |
---|
699 | buffer.insert(count, '='); |
---|
700 | count += 79; |
---|
701 | } |
---|
702 | final String result = buffer.toString(); |
---|
703 | return result; |
---|
704 | } |
---|
705 | } |
---|