1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| package javax.mail.internet; |
19 |
| |
20 |
| import java.io.BufferedInputStream; |
21 |
| import java.io.ByteArrayInputStream; |
22 |
| import java.io.ByteArrayOutputStream; |
23 |
| import java.io.IOException; |
24 |
| import java.io.InputStream; |
25 |
| import java.io.ObjectStreamException; |
26 |
| import java.io.OutputStream; |
27 |
| import java.io.UnsupportedEncodingException; |
28 |
| import java.util.ArrayList; |
29 |
| import java.util.Arrays; |
30 |
| import java.util.Date; |
31 |
| import java.util.Enumeration; |
32 |
| import java.util.HashMap; |
33 |
| import java.util.List; |
34 |
| import java.util.Map; |
35 |
| |
36 |
| import javax.activation.DataHandler; |
37 |
| import javax.mail.Address; |
38 |
| import javax.mail.Flags; |
39 |
| import javax.mail.Folder; |
40 |
| import javax.mail.Message; |
41 |
| import javax.mail.MessagingException; |
42 |
| import javax.mail.Multipart; |
43 |
| import javax.mail.Part; |
44 |
| import javax.mail.Session; |
45 |
| import javax.mail.internet.HeaderTokenizer.Token; |
46 |
| |
47 |
| import org.apache.geronimo.mail.util.ASCIIUtil; |
48 |
| import org.apache.geronimo.mail.util.SessionUtil; |
49 |
| |
50 |
| |
51 |
| |
52 |
| |
53 |
| public class MimeMessage extends Message implements MimePart { |
54 |
| private static final String MIME_ADDRESS_STRICT = "mail.mime.address.strict"; |
55 |
| private static final String MIME_DECODEFILENAME = "mail.mime.decodefilename"; |
56 |
| private static final String MIME_ENCODEFILENAME = "mail.mime.encodefilename"; |
57 |
| |
58 |
| private static final String MAIL_ALTERNATES = "mail.alternates"; |
59 |
| private static final String MAIL_REPLYALLCC = "mail.replyallcc"; |
60 |
| |
61 |
| |
62 |
| |
63 |
| |
64 |
| |
65 |
| public static class RecipientType extends Message.RecipientType { |
66 |
| |
67 |
| |
68 |
| |
69 |
| public static final RecipientType NEWSGROUPS = new RecipientType("Newsgroups"); |
70 |
| |
71 |
1
| protected RecipientType(String type) {
|
72 |
1
| super(type);
|
73 |
| } |
74 |
| |
75 |
| |
76 |
| |
77 |
| |
78 |
| |
79 |
| |
80 |
0
| protected Object readResolve() throws ObjectStreamException {
|
81 |
0
| if (this.type.equals("Newsgroups")) {
|
82 |
0
| return NEWSGROUPS;
|
83 |
| } else { |
84 |
0
| return super.readResolve();
|
85 |
| } |
86 |
| } |
87 |
| } |
88 |
| |
89 |
| |
90 |
| |
91 |
| |
92 |
| protected DataHandler dh; |
93 |
| |
94 |
| |
95 |
| |
96 |
| protected byte[] content; |
97 |
| |
98 |
| |
99 |
| |
100 |
| |
101 |
| |
102 |
| protected InputStream contentStream; |
103 |
| |
104 |
| |
105 |
| |
106 |
| protected InternetHeaders headers; |
107 |
| |
108 |
| |
109 |
| |
110 |
| protected Flags flags; |
111 |
| |
112 |
| |
113 |
| |
114 |
| |
115 |
| protected boolean modified; |
116 |
| |
117 |
| |
118 |
| |
119 |
| protected boolean saved; |
120 |
| |
121 |
| private final MailDateFormat dateFormat = new MailDateFormat(); |
122 |
| |
123 |
| |
124 |
| |
125 |
| |
126 |
| |
127 |
| |
128 |
| |
129 |
| |
130 |
14
| public MimeMessage(Session session) {
|
131 |
14
| super(session);
|
132 |
14
| headers = new InternetHeaders();
|
133 |
14
| flags = new Flags();
|
134 |
| |
135 |
14
| modified = true;
|
136 |
14
| saved = false;
|
137 |
| } |
138 |
| |
139 |
| |
140 |
| |
141 |
| |
142 |
| |
143 |
| |
144 |
| |
145 |
| |
146 |
2
| public MimeMessage(Session session, InputStream in) throws MessagingException {
|
147 |
2
| this(session);
|
148 |
2
| parse(in);
|
149 |
| |
150 |
2
| modified = false;
|
151 |
| |
152 |
2
| saved = true;
|
153 |
| } |
154 |
| |
155 |
| |
156 |
| |
157 |
| |
158 |
| |
159 |
| |
160 |
| |
161 |
1
| public MimeMessage(MimeMessage message) throws MessagingException {
|
162 |
1
| super(message.session);
|
163 |
| |
164 |
| |
165 |
| |
166 |
| |
167 |
| |
168 |
| |
169 |
| |
170 |
| |
171 |
1
| ByteArrayOutputStream copy = new ByteArrayOutputStream();
|
172 |
| |
173 |
1
| try {
|
174 |
| |
175 |
1
| message.writeTo(copy);
|
176 |
1
| copy.close();
|
177 |
| |
178 |
| |
179 |
1
| ByteArrayInputStream inData = new ByteArrayInputStream(copy.toByteArray());
|
180 |
| |
181 |
1
| inData.close();
|
182 |
1
| parse (inData);
|
183 |
| |
184 |
1
| saved = true;
|
185 |
| |
186 |
1
| modified = false;
|
187 |
| } catch (IOException e) { |
188 |
| |
189 |
| |
190 |
| |
191 |
0
| throw new MessagingException("Error copying MimeMessage data", e);
|
192 |
| } |
193 |
| } |
194 |
| |
195 |
| |
196 |
| |
197 |
| |
198 |
| |
199 |
| |
200 |
| |
201 |
3
| protected MimeMessage(Folder folder, int number) {
|
202 |
3
| super(folder, number);
|
203 |
3
| headers = new InternetHeaders();
|
204 |
3
| flags = new Flags();
|
205 |
| |
206 |
| |
207 |
3
| saved = true;
|
208 |
| |
209 |
3
| modified = true;
|
210 |
| } |
211 |
| |
212 |
| |
213 |
| |
214 |
| |
215 |
| |
216 |
| |
217 |
| |
218 |
| |
219 |
| |
220 |
0
| protected MimeMessage(Folder folder, InputStream in, int number) throws MessagingException {
|
221 |
0
| this(folder, number);
|
222 |
0
| parse(in);
|
223 |
| |
224 |
0
| modified = false;
|
225 |
| |
226 |
0
| saved = true;
|
227 |
| } |
228 |
| |
229 |
| |
230 |
| |
231 |
| |
232 |
| |
233 |
| |
234 |
| |
235 |
| |
236 |
| |
237 |
| |
238 |
| |
239 |
0
| protected MimeMessage(Folder folder, InternetHeaders headers, byte[] content, int number) throws MessagingException {
|
240 |
0
| this(folder, number);
|
241 |
0
| this.headers = headers;
|
242 |
0
| this.content = content;
|
243 |
| |
244 |
0
| modified = false;
|
245 |
| } |
246 |
| |
247 |
| |
248 |
| |
249 |
| |
250 |
| |
251 |
| |
252 |
| |
253 |
3
| protected void parse(InputStream in) throws MessagingException {
|
254 |
3
| in = new BufferedInputStream(in);
|
255 |
| |
256 |
3
| headers = new InternetHeaders(in);
|
257 |
| |
258 |
| |
259 |
| |
260 |
3
| ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
261 |
3
| try {
|
262 |
3
| byte buffer[] = new byte[1024];
|
263 |
3
| int count;
|
264 |
?
| while ((count = in.read(buffer, 0, 1024)) != -1) {
|
265 |
3
| baos.write(buffer, 0, count);
|
266 |
| } |
267 |
| } catch (Exception e) { |
268 |
0
| throw new MessagingException(e.toString(), e);
|
269 |
| } |
270 |
| |
271 |
3
| content = baos.toByteArray();
|
272 |
| } |
273 |
| |
274 |
| |
275 |
| |
276 |
| |
277 |
| |
278 |
| |
279 |
| |
280 |
| |
281 |
| |
282 |
| |
283 |
6
| public Address[] getFrom() throws MessagingException {
|
284 |
| |
285 |
6
| boolean strict = isStrictAddressing();
|
286 |
6
| Address[] result = getHeaderAsInternetAddresses("From", strict);
|
287 |
6
| if (result == null) {
|
288 |
2
| result = getHeaderAsInternetAddresses("Sender", strict);
|
289 |
| } |
290 |
6
| return result;
|
291 |
| } |
292 |
| |
293 |
| |
294 |
| |
295 |
| |
296 |
| |
297 |
| |
298 |
| |
299 |
| |
300 |
| |
301 |
| |
302 |
3
| public void setFrom(Address address) throws MessagingException {
|
303 |
3
| setHeader("From", address);
|
304 |
| } |
305 |
| |
306 |
| |
307 |
| |
308 |
| |
309 |
| |
310 |
| |
311 |
1
| public void setFrom() throws MessagingException {
|
312 |
1
| InternetAddress address = InternetAddress.getLocalAddress(session);
|
313 |
| |
314 |
1
| if (address == null) {
|
315 |
0
| throw new MessagingException("No local address defined");
|
316 |
| } |
317 |
1
| setFrom(address);
|
318 |
| } |
319 |
| |
320 |
| |
321 |
| |
322 |
| |
323 |
| |
324 |
| |
325 |
| |
326 |
| |
327 |
1
| public void addFrom(Address[] addresses) throws MessagingException {
|
328 |
1
| addHeader("From", addresses);
|
329 |
| } |
330 |
| |
331 |
| |
332 |
| |
333 |
| |
334 |
| |
335 |
| |
336 |
| |
337 |
4
| public Address getSender() throws MessagingException {
|
338 |
4
| Address[] addrs = getHeaderAsInternetAddresses("Sender", isStrictAddressing());
|
339 |
4
| return addrs.length > 0 ? addrs[0] : null;
|
340 |
| } |
341 |
| |
342 |
| |
343 |
| |
344 |
| |
345 |
| |
346 |
| |
347 |
| |
348 |
| |
349 |
| |
350 |
| |
351 |
4
| public void setSender(Address address) throws MessagingException {
|
352 |
4
| setHeader("Sender", address);
|
353 |
| } |
354 |
| |
355 |
| |
356 |
| |
357 |
| |
358 |
| |
359 |
| |
360 |
| |
361 |
| |
362 |
| |
363 |
| |
364 |
| |
365 |
| |
366 |
| |
367 |
| |
368 |
| |
369 |
32
| public Address[] getRecipients(Message.RecipientType type) throws MessagingException {
|
370 |
| |
371 |
| |
372 |
32
| if (type == RecipientType.NEWSGROUPS) {
|
373 |
8
| return getHeaderAsNewsAddresses(getHeaderForRecipientType(type));
|
374 |
| } |
375 |
| |
376 |
24
| return getHeaderAsInternetAddresses(getHeaderForRecipientType(type), isStrictAddressing());
|
377 |
| } |
378 |
| |
379 |
| |
380 |
| |
381 |
| |
382 |
| |
383 |
| |
384 |
| |
385 |
| |
386 |
| |
387 |
| |
388 |
| |
389 |
| |
390 |
| |
391 |
| |
392 |
| |
393 |
6
| public Address[] getAllRecipients() throws MessagingException {
|
394 |
6
| List recipients = new ArrayList();
|
395 |
6
| addRecipientsToList(recipients, RecipientType.TO);
|
396 |
6
| addRecipientsToList(recipients, RecipientType.CC);
|
397 |
6
| addRecipientsToList(recipients, RecipientType.BCC);
|
398 |
6
| addRecipientsToList(recipients, RecipientType.NEWSGROUPS);
|
399 |
6
| return (Address[]) recipients.toArray(new Address[recipients.size()]);
|
400 |
| } |
401 |
| |
402 |
| |
403 |
| |
404 |
| |
405 |
| |
406 |
| |
407 |
| |
408 |
| |
409 |
| |
410 |
| |
411 |
24
| private void addRecipientsToList(List list, Message.RecipientType type) throws MessagingException {
|
412 |
| |
413 |
24
| Address[] recipients;
|
414 |
24
| if (type == RecipientType.NEWSGROUPS) {
|
415 |
6
| recipients = getHeaderAsNewsAddresses(getHeaderForRecipientType(type));
|
416 |
| } |
417 |
| else { |
418 |
18
| recipients = getHeaderAsInternetAddresses(getHeaderForRecipientType(type), isStrictAddressing());
|
419 |
| } |
420 |
24
| if (recipients != null) {
|
421 |
14
| list.addAll(Arrays.asList(recipients));
|
422 |
| } |
423 |
| } |
424 |
| |
425 |
| |
426 |
| |
427 |
| |
428 |
| |
429 |
| |
430 |
| |
431 |
| |
432 |
| |
433 |
| |
434 |
13
| public void setRecipients(Message.RecipientType type, Address[] addresses) throws MessagingException {
|
435 |
13
| setHeader(getHeaderForRecipientType(type), addresses);
|
436 |
| } |
437 |
| |
438 |
| |
439 |
| |
440 |
| |
441 |
| |
442 |
| |
443 |
| |
444 |
| |
445 |
| |
446 |
| |
447 |
| |
448 |
| |
449 |
9
| public void setRecipients(Message.RecipientType type, String address) throws MessagingException {
|
450 |
9
| setOrRemoveHeader(getHeaderForRecipientType(type), address);
|
451 |
| } |
452 |
| |
453 |
| |
454 |
| |
455 |
| |
456 |
| |
457 |
| |
458 |
| |
459 |
| |
460 |
| |
461 |
| |
462 |
7
| public void addRecipients(Message.RecipientType type, Address[] address) throws MessagingException {
|
463 |
7
| addHeader(getHeaderForRecipientType(type), address);
|
464 |
| } |
465 |
| |
466 |
| |
467 |
| |
468 |
| |
469 |
| |
470 |
| |
471 |
| |
472 |
| |
473 |
| |
474 |
4
| public void addRecipients(Message.RecipientType type, String address) throws MessagingException {
|
475 |
4
| addHeader(getHeaderForRecipientType(type), address);
|
476 |
| } |
477 |
| |
478 |
| |
479 |
| |
480 |
| |
481 |
| |
482 |
| |
483 |
| |
484 |
| |
485 |
| |
486 |
3
| public Address[] getReplyTo() throws MessagingException {
|
487 |
3
| Address[] addresses = getHeaderAsInternetAddresses("Reply-To", isStrictAddressing());
|
488 |
3
| if (addresses == null) {
|
489 |
0
| addresses = getFrom();
|
490 |
| } |
491 |
3
| return addresses;
|
492 |
| } |
493 |
| |
494 |
| |
495 |
| |
496 |
| |
497 |
| |
498 |
| |
499 |
| |
500 |
| |
501 |
| |
502 |
3
| public void setReplyTo(Address[] address) throws MessagingException {
|
503 |
3
| setHeader("Reply-To", address);
|
504 |
| } |
505 |
| |
506 |
| |
507 |
| |
508 |
| |
509 |
| |
510 |
| |
511 |
| |
512 |
| |
513 |
| |
514 |
| |
515 |
3
| public String getSubject() throws MessagingException {
|
516 |
3
| String subject = getSingleHeader("Subject");
|
517 |
3
| if (subject == null) {
|
518 |
1
| return null;
|
519 |
| } else { |
520 |
2
| try {
|
521 |
| |
522 |
2
| return MimeUtility.decodeText(ASCIIUtil.unfold(subject));
|
523 |
| } catch (UnsupportedEncodingException e) { |
524 |
| |
525 |
| } |
526 |
| } |
527 |
| |
528 |
0
| return subject;
|
529 |
| } |
530 |
| |
531 |
| |
532 |
| |
533 |
| |
534 |
| |
535 |
| |
536 |
| |
537 |
| |
538 |
| |
539 |
| |
540 |
| |
541 |
| |
542 |
2
| public void setSubject(String subject) throws MessagingException {
|
543 |
| |
544 |
2
| setSubject(subject, null);
|
545 |
| } |
546 |
| |
547 |
3
| public void setSubject(String subject, String charset) throws MessagingException {
|
548 |
| |
549 |
3
| if (subject == null) {
|
550 |
1
| removeHeader("Subject");
|
551 |
| } |
552 |
| else { |
553 |
2
| try {
|
554 |
2
| String s = ASCIIUtil.fold(9, MimeUtility.encodeText(subject, charset, null));
|
555 |
| |
556 |
2
| setHeader("Subject", ASCIIUtil.fold(9, MimeUtility.encodeText(subject, charset, null)));
|
557 |
| } catch (UnsupportedEncodingException e) { |
558 |
0
| throw new MessagingException("Encoding error", e);
|
559 |
| } |
560 |
| } |
561 |
| } |
562 |
| |
563 |
| |
564 |
| |
565 |
| |
566 |
| |
567 |
| |
568 |
| |
569 |
| |
570 |
0
| public Date getSentDate() throws MessagingException {
|
571 |
0
| String value = getSingleHeader("Date");
|
572 |
0
| if (value == null) {
|
573 |
0
| return null;
|
574 |
| } |
575 |
0
| try {
|
576 |
0
| return dateFormat.parse(value);
|
577 |
| } catch (java.text.ParseException e) { |
578 |
0
| return null;
|
579 |
| } |
580 |
| } |
581 |
| |
582 |
| |
583 |
| |
584 |
| |
585 |
| |
586 |
| |
587 |
| |
588 |
| |
589 |
| |
590 |
0
| public void setSentDate(Date sent) throws MessagingException {
|
591 |
0
| setOrRemoveHeader("Date", dateFormat.format(sent));
|
592 |
| } |
593 |
| |
594 |
| |
595 |
| |
596 |
| |
597 |
| |
598 |
| |
599 |
| |
600 |
| |
601 |
0
| public Date getReceivedDate() throws MessagingException {
|
602 |
0
| return null;
|
603 |
| } |
604 |
| |
605 |
| |
606 |
| |
607 |
| |
608 |
| |
609 |
| |
610 |
| |
611 |
| |
612 |
| |
613 |
| |
614 |
0
| public int getSize() throws MessagingException {
|
615 |
0
| if (content != null) {
|
616 |
0
| return content.length;
|
617 |
| } |
618 |
0
| if (contentStream != null) {
|
619 |
0
| try {
|
620 |
0
| int size = contentStream.available();
|
621 |
0
| if (size > 0) {
|
622 |
0
| return size;
|
623 |
| } |
624 |
| } catch (IOException e) { |
625 |
| |
626 |
| } |
627 |
| } |
628 |
0
| return -1;
|
629 |
| } |
630 |
| |
631 |
| |
632 |
| |
633 |
| |
634 |
| |
635 |
| |
636 |
| |
637 |
| |
638 |
| |
639 |
| |
640 |
| |
641 |
0
| public int getLineCount() throws MessagingException {
|
642 |
0
| return -1;
|
643 |
| } |
644 |
| |
645 |
| |
646 |
| |
647 |
| |
648 |
| |
649 |
| |
650 |
| |
651 |
| |
652 |
6
| public String getContentType() throws MessagingException {
|
653 |
6
| String value = getSingleHeader("Content-Type");
|
654 |
6
| if (value == null) {
|
655 |
0
| value = "text/plain";
|
656 |
| } |
657 |
6
| return value;
|
658 |
| } |
659 |
| |
660 |
| |
661 |
| |
662 |
| |
663 |
| |
664 |
| |
665 |
| |
666 |
| |
667 |
| |
668 |
| |
669 |
| |
670 |
0
| public boolean isMimeType(String type) throws MessagingException {
|
671 |
0
| return new ContentType(getContentType()).match(type);
|
672 |
| } |
673 |
| |
674 |
| |
675 |
| |
676 |
| |
677 |
| |
678 |
| |
679 |
| |
680 |
| |
681 |
| |
682 |
0
| public String getDisposition() throws MessagingException {
|
683 |
0
| String disp = getSingleHeader("Content-Disposition");
|
684 |
0
| if (disp != null) {
|
685 |
0
| return new ContentDisposition(disp).getDisposition();
|
686 |
| } |
687 |
0
| return null;
|
688 |
| } |
689 |
| |
690 |
| |
691 |
| |
692 |
| |
693 |
| |
694 |
| |
695 |
| |
696 |
| |
697 |
| |
698 |
| |
699 |
| |
700 |
0
| public void setDisposition(String disposition) throws MessagingException {
|
701 |
0
| if (disposition == null) {
|
702 |
0
| removeHeader("Content-Disposition");
|
703 |
| } |
704 |
| else { |
705 |
| |
706 |
0
| String currentHeader = getSingleHeader("Content-Disposition");
|
707 |
0
| if (currentHeader != null) {
|
708 |
0
| ContentDisposition content = new ContentDisposition(currentHeader);
|
709 |
0
| content.setDisposition(disposition);
|
710 |
0
| setHeader("Content-Disposition", content.toString());
|
711 |
| } |
712 |
| else { |
713 |
| |
714 |
0
| setHeader("Content-Disposition", disposition);
|
715 |
| } |
716 |
| } |
717 |
| } |
718 |
| |
719 |
| |
720 |
| |
721 |
| |
722 |
| |
723 |
| |
724 |
| |
725 |
| |
726 |
4
| public String getEncoding() throws MessagingException {
|
727 |
| |
728 |
4
| String encoding = getSingleHeader("Content-Transfer-Encoding");
|
729 |
4
| if (encoding != null) {
|
730 |
| |
731 |
| |
732 |
0
| HeaderTokenizer tokenizer = new HeaderTokenizer(encoding, HeaderTokenizer.MIME);
|
733 |
| |
734 |
0
| Token token = tokenizer.next();
|
735 |
0
| while (token.getType() != Token.EOF) {
|
736 |
| |
737 |
0
| if (token.getType() == Token.ATOM) {
|
738 |
0
| return token.getValue();
|
739 |
| } |
740 |
| } |
741 |
| |
742 |
| |
743 |
0
| return encoding;
|
744 |
| } |
745 |
| |
746 |
4
| return null;
|
747 |
| } |
748 |
| |
749 |
| |
750 |
| |
751 |
| |
752 |
| |
753 |
| |
754 |
| |
755 |
| |
756 |
0
| public String getContentID() throws MessagingException {
|
757 |
0
| return getSingleHeader("Content-ID");
|
758 |
| } |
759 |
| |
760 |
0
| public void setContentID(String cid) throws MessagingException {
|
761 |
0
| setOrRemoveHeader("Content-ID", cid);
|
762 |
| } |
763 |
| |
764 |
0
| public String getContentMD5() throws MessagingException {
|
765 |
0
| return getSingleHeader("Content-MD5");
|
766 |
| } |
767 |
| |
768 |
0
| public void setContentMD5(String md5) throws MessagingException {
|
769 |
0
| setOrRemoveHeader("Content-MD5", md5);
|
770 |
| } |
771 |
| |
772 |
3
| public String getDescription() throws MessagingException {
|
773 |
3
| String description = getSingleHeader("Content-Description");
|
774 |
3
| if (description != null) {
|
775 |
2
| try {
|
776 |
| |
777 |
2
| return MimeUtility.decodeText(ASCIIUtil.unfold(description));
|
778 |
| } catch (UnsupportedEncodingException e) { |
779 |
| |
780 |
| } |
781 |
| } |
782 |
| |
783 |
1
| return description;
|
784 |
| } |
785 |
| |
786 |
2
| public void setDescription(String description) throws MessagingException {
|
787 |
2
| setDescription(description, null);
|
788 |
| } |
789 |
| |
790 |
3
| public void setDescription(String description, String charset) throws MessagingException {
|
791 |
3
| if (description == null) {
|
792 |
1
| removeHeader("Content-Description");
|
793 |
| } |
794 |
| else { |
795 |
2
| try {
|
796 |
2
| setHeader("Content-Description", ASCIIUtil.fold(21, MimeUtility.encodeText(description, charset, null)));
|
797 |
| } catch (UnsupportedEncodingException e) { |
798 |
0
| throw new MessagingException(e.getMessage(), e);
|
799 |
| } |
800 |
| } |
801 |
| |
802 |
| } |
803 |
| |
804 |
0
| public String[] getContentLanguage() throws MessagingException {
|
805 |
0
| return getHeader("Content-Language");
|
806 |
| } |
807 |
| |
808 |
0
| public void setContentLanguage(String[] languages) throws MessagingException {
|
809 |
0
| if (languages == null) {
|
810 |
0
| removeHeader("Content-Language");
|
811 |
0
| } else if (languages.length == 1) {
|
812 |
0
| setHeader("Content-Language", languages[0]);
|
813 |
| } else { |
814 |
0
| StringBuffer buf = new StringBuffer(languages.length * 20);
|
815 |
0
| buf.append(languages[0]);
|
816 |
0
| for (int i = 1; i < languages.length; i++) {
|
817 |
0
| buf.append(',').append(languages[i]);
|
818 |
| } |
819 |
0
| setHeader("Content-Language", buf.toString());
|
820 |
| } |
821 |
| } |
822 |
| |
823 |
0
| public String getMessageID() throws MessagingException {
|
824 |
0
| return getSingleHeader("Message-ID");
|
825 |
| } |
826 |
| |
827 |
0
| public String getFileName() throws MessagingException {
|
828 |
| |
829 |
0
| String disposition = getDisposition();
|
830 |
0
| String filename = null;
|
831 |
| |
832 |
0
| if (disposition != null) {
|
833 |
0
| filename = new ContentDisposition(disposition).getParameter("filename");
|
834 |
| } |
835 |
| |
836 |
| |
837 |
| |
838 |
0
| if (filename == null) {
|
839 |
0
| String type = getContentType();
|
840 |
0
| if (type != null) {
|
841 |
0
| try {
|
842 |
0
| filename = new ContentType(type).getParameter("name");
|
843 |
| } catch (ParseException e) { |
844 |
| } |
845 |
| } |
846 |
| } |
847 |
| |
848 |
0
| if (filename != null && SessionUtil.getBooleanProperty(session, MIME_DECODEFILENAME, false)) {
|
849 |
0
| try {
|
850 |
0
| filename = MimeUtility.decodeText(filename);
|
851 |
| } catch (UnsupportedEncodingException e) { |
852 |
0
| throw new MessagingException("Unable to decode filename", e);
|
853 |
| } |
854 |
| } |
855 |
| |
856 |
0
| return filename;
|
857 |
| } |
858 |
| |
859 |
| |
860 |
0
| public void setFileName(String name) throws MessagingException {
|
861 |
| |
862 |
| |
863 |
0
| if (name != null && SessionUtil.getBooleanProperty(session, MIME_ENCODEFILENAME, false)) {
|
864 |
0
| try {
|
865 |
0
| name = MimeUtility.encodeText(name);
|
866 |
| } catch (UnsupportedEncodingException e) { |
867 |
0
| throw new MessagingException("Unable to encode filename", e);
|
868 |
| } |
869 |
| } |
870 |
| |
871 |
| |
872 |
0
| String disposition = getDisposition();
|
873 |
| |
874 |
0
| if (disposition == null) {
|
875 |
0
| disposition = Part.ATTACHMENT;
|
876 |
| } |
877 |
| |
878 |
0
| ContentDisposition contentDisposition = new ContentDisposition(disposition);
|
879 |
0
| contentDisposition.setParameter("filename", name);
|
880 |
| |
881 |
| |
882 |
0
| setDisposition(contentDisposition.toString());
|
883 |
| } |
884 |
| |
885 |
0
| public InputStream getInputStream() throws MessagingException, IOException {
|
886 |
0
| return getDataHandler().getInputStream();
|
887 |
| } |
888 |
| |
889 |
1
| protected InputStream getContentStream() throws MessagingException {
|
890 |
1
| if (contentStream != null) {
|
891 |
0
| return contentStream;
|
892 |
| } |
893 |
| |
894 |
1
| if (content != null) {
|
895 |
1
| return new ByteArrayInputStream(content);
|
896 |
| } else { |
897 |
0
| throw new MessagingException("No content");
|
898 |
| } |
899 |
| } |
900 |
| |
901 |
0
| public InputStream getRawInputStream() throws MessagingException {
|
902 |
0
| return getContentStream();
|
903 |
| } |
904 |
| |
905 |
4
| public synchronized DataHandler getDataHandler() throws MessagingException {
|
906 |
4
| if (dh == null) {
|
907 |
1
| dh = new DataHandler(new MimePartDataSource(this));
|
908 |
| } |
909 |
4
| return dh;
|
910 |
| } |
911 |
| |
912 |
2
| public Object getContent() throws MessagingException, IOException {
|
913 |
2
| return getDataHandler().getContent();
|
914 |
| } |
915 |
| |
916 |
2
| public void setDataHandler(DataHandler handler) throws MessagingException {
|
917 |
2
| dh = handler;
|
918 |
| |
919 |
| |
920 |
| |
921 |
2
| removeHeader("Content-Type");
|
922 |
2
| removeHeader("Content-Transfer-Encoding");
|
923 |
| } |
924 |
| |
925 |
0
| public void setContent(Object content, String type) throws MessagingException {
|
926 |
0
| setDataHandler(new DataHandler(content, type));
|
927 |
| } |
928 |
| |
929 |
0
| public void setText(String text) throws MessagingException {
|
930 |
0
| setText(text, null);
|
931 |
| } |
932 |
| |
933 |
0
| public void setText(String text, String charset) throws MessagingException {
|
934 |
| |
935 |
0
| if (charset == null) {
|
936 |
| |
937 |
0
| if (!ASCIIUtil.isAscii(text)) {
|
938 |
0
| charset = MimeUtility.getDefaultMIMECharset();
|
939 |
| } |
940 |
| else { |
941 |
0
| charset = "us-ascii";
|
942 |
| } |
943 |
| } |
944 |
0
| setContent(text, "text/plain; charset=" + MimeUtility.quote(charset, HeaderTokenizer.MIME));
|
945 |
| } |
946 |
| |
947 |
2
| public void setContent(Multipart part) throws MessagingException {
|
948 |
2
| setDataHandler(new DataHandler(part, part.getContentType()));
|
949 |
2
| part.setParent(this);
|
950 |
| } |
951 |
| |
952 |
0
| public Message reply(boolean replyToAll) throws MessagingException {
|
953 |
| |
954 |
0
| MimeMessage reply = new MimeMessage(session);
|
955 |
| |
956 |
| |
957 |
0
| String newSubject = getSubject();
|
958 |
0
| if (newSubject != null) {
|
959 |
| |
960 |
| |
961 |
0
| if (!newSubject.regionMatches(true, 0, "Re: ", 0, 4)) {
|
962 |
0
| newSubject = "Re: " + newSubject;
|
963 |
| } |
964 |
0
| reply.setSubject(newSubject);
|
965 |
| } |
966 |
| |
967 |
0
| Address[] toRecipients = getReplyTo();
|
968 |
| |
969 |
| |
970 |
0
| reply.setRecipients(Message.RecipientType.TO, getReplyTo());
|
971 |
| |
972 |
| |
973 |
0
| if (replyToAll) {
|
974 |
| |
975 |
| |
976 |
0
| HashMap masterList = new HashMap();
|
977 |
| |
978 |
| |
979 |
0
| InternetAddress localMail = InternetAddress.getLocalAddress(session);
|
980 |
0
| if (localMail != null) {
|
981 |
0
| masterList.put(localMail.getAddress(), localMail);
|
982 |
| } |
983 |
| |
984 |
0
| String alternates = session.getProperty(MAIL_ALTERNATES);
|
985 |
0
| if (alternates != null) {
|
986 |
| |
987 |
0
| Address[] alternateList = InternetAddress.parse(alternates, false);
|
988 |
0
| mergeAddressList(masterList, alternateList);
|
989 |
| } |
990 |
| |
991 |
| |
992 |
| |
993 |
| |
994 |
| |
995 |
| |
996 |
0
| Address[] toList = pruneAddresses(masterList, getRecipients(Message.RecipientType.TO));
|
997 |
0
| if (toList.length != 0) {
|
998 |
| |
999 |
| |
1000 |
| |
1001 |
0
| if (SessionUtil.getBooleanProperty(session, MAIL_REPLYALLCC, false)) {
|
1002 |
0
| reply.addRecipients(Message.RecipientType.CC, toList);
|
1003 |
| } |
1004 |
| else { |
1005 |
0
| reply.addRecipients(Message.RecipientType.TO, toList);
|
1006 |
| } |
1007 |
| } |
1008 |
| |
1009 |
0
| toList = pruneAddresses(masterList, getRecipients(Message.RecipientType.CC));
|
1010 |
0
| if (toList.length != 0) {
|
1011 |
0
| reply.addRecipients(Message.RecipientType.CC, toList);
|
1012 |
| } |
1013 |
| |
1014 |
| |
1015 |
| |
1016 |
0
| toList = getRecipients(RecipientType.NEWSGROUPS);
|
1017 |
0
| if (toList != null && toList.length != 0) {
|
1018 |
0
| reply.addRecipients(RecipientType.NEWSGROUPS, toList);
|
1019 |
| } |
1020 |
| } |
1021 |
| |
1022 |
| |
1023 |
| |
1024 |
| |
1025 |
| |
1026 |
0
| setFlags(new Flags(Flags.Flag.ANSWERED), true);
|
1027 |
| |
1028 |
0
| return reply;
|
1029 |
| } |
1030 |
| |
1031 |
| |
1032 |
| |
1033 |
| |
1034 |
| |
1035 |
| |
1036 |
| |
1037 |
| |
1038 |
| |
1039 |
0
| private void mergeAddressList(Map master, Address[] list) {
|
1040 |
| |
1041 |
0
| if (list == null) {
|
1042 |
0
| return;
|
1043 |
| } |
1044 |
0
| for (int i = 0; i < list.length; i++) {
|
1045 |
0
| InternetAddress address = (InternetAddress)list[i];
|
1046 |
| |
1047 |
| |
1048 |
0
| if (!master.containsKey(address.getAddress())) {
|
1049 |
0
| master.put(address.getAddress(), address);
|
1050 |
| } |
1051 |
| } |
1052 |
| } |
1053 |
| |
1054 |
| |
1055 |
| |
1056 |
| |
1057 |
| |
1058 |
| |
1059 |
| |
1060 |
| |
1061 |
| |
1062 |
| |
1063 |
| |
1064 |
| |
1065 |
0
| private Address[] pruneAddresses(Map master, Address[] list) {
|
1066 |
| |
1067 |
0
| if (list == null) {
|
1068 |
0
| return new Address[0];
|
1069 |
| } |
1070 |
| |
1071 |
| |
1072 |
0
| ArrayList prunedList = new ArrayList(list.length);
|
1073 |
0
| for (int i = 0; i < list.length; i++) {
|
1074 |
0
| InternetAddress address = (InternetAddress)list[i];
|
1075 |
| |
1076 |
| |
1077 |
| |
1078 |
0
| if (!master.containsKey(address.getAddress())) {
|
1079 |
0
| master.put(address.getAddress(), address);
|
1080 |
0
| prunedList.add(address);
|
1081 |
| } |
1082 |
| } |
1083 |
| |
1084 |
0
| return (Address[])prunedList.toArray(new Address[0]);
|
1085 |
| } |
1086 |
| |
1087 |
| |
1088 |
| |
1089 |
| |
1090 |
| |
1091 |
| |
1092 |
| |
1093 |
| |
1094 |
| |
1095 |
| |
1096 |
3
| public void writeTo(OutputStream out) throws MessagingException, IOException {
|
1097 |
3
| writeTo(out, null);
|
1098 |
| } |
1099 |
| |
1100 |
| |
1101 |
| |
1102 |
| |
1103 |
| |
1104 |
| |
1105 |
| |
1106 |
| |
1107 |
| |
1108 |
| |
1109 |
| |
1110 |
| |
1111 |
| |
1112 |
3
| public void writeTo(OutputStream out, String[] ignoreHeaders) throws MessagingException, IOException {
|
1113 |
| |
1114 |
3
| if (!saved) {
|
1115 |
2
| saveChanges();
|
1116 |
| } |
1117 |
| |
1118 |
| |
1119 |
3
| headers.writeTo(out, ignoreHeaders);
|
1120 |
| |
1121 |
3
| out.write('\r');
|
1122 |
3
| out.write('\n');
|
1123 |
| |
1124 |
| |
1125 |
| |
1126 |
3
| if (modified) {
|
1127 |
3
| dh.writeTo(MimeUtility.encode(out, getEncoding()));
|
1128 |
| } else { |
1129 |
| |
1130 |
0
| if (content != null) {
|
1131 |
0
| out.write(content);
|
1132 |
| } |
1133 |
| else { |
1134 |
| |
1135 |
| |
1136 |
0
| InputStream in = getContentStream();
|
1137 |
| |
1138 |
0
| byte[] buffer = new byte[8192];
|
1139 |
0
| int length = in.read(buffer);
|
1140 |
| |
1141 |
0
| while (length > 0) {
|
1142 |
0
| out.write(buffer, 0, length);
|
1143 |
0
| length = in.read(buffer);
|
1144 |
| } |
1145 |
0
| in.close();
|
1146 |
| } |
1147 |
| } |
1148 |
| |
1149 |
| |
1150 |
3
| out.flush();
|
1151 |
| } |
1152 |
| |
1153 |
| |
1154 |
| |
1155 |
| |
1156 |
| |
1157 |
| |
1158 |
| |
1159 |
| |
1160 |
| |
1161 |
| |
1162 |
| |
1163 |
| |
1164 |
21
| public String[] getHeader(String name) throws MessagingException {
|
1165 |
21
| return headers.getHeader(name);
|
1166 |
| } |
1167 |
| |
1168 |
| |
1169 |
| |
1170 |
| |
1171 |
| |
1172 |
| |
1173 |
| |
1174 |
| |
1175 |
| |
1176 |
| |
1177 |
| |
1178 |
| |
1179 |
| |
1180 |
71
| public String getHeader(String name, String delimiter) throws MessagingException {
|
1181 |
71
| return headers.getHeader(name, delimiter);
|
1182 |
| } |
1183 |
| |
1184 |
| |
1185 |
| |
1186 |
| |
1187 |
| |
1188 |
| |
1189 |
| |
1190 |
| |
1191 |
| |
1192 |
14
| public void setHeader(String name, String value) throws MessagingException {
|
1193 |
14
| headers.setHeader(name, value);
|
1194 |
| } |
1195 |
| |
1196 |
| |
1197 |
| |
1198 |
| |
1199 |
| |
1200 |
| |
1201 |
| |
1202 |
| |
1203 |
| |
1204 |
| |
1205 |
| |
1206 |
9
| private void setOrRemoveHeader(String name, String value) throws MessagingException {
|
1207 |
9
| if (value == null) {
|
1208 |
5
| headers.removeHeader(name);
|
1209 |
| } |
1210 |
| else { |
1211 |
4
| headers.setHeader(name, value);
|
1212 |
| } |
1213 |
| } |
1214 |
| |
1215 |
| |
1216 |
| |
1217 |
| |
1218 |
| |
1219 |
| |
1220 |
| |
1221 |
| |
1222 |
| |
1223 |
| |
1224 |
4
| public void addHeader(String name, String value) throws MessagingException {
|
1225 |
4
| headers.addHeader(name, value);
|
1226 |
| } |
1227 |
| |
1228 |
| |
1229 |
| |
1230 |
| |
1231 |
| |
1232 |
| |
1233 |
| |
1234 |
| |
1235 |
8
| public void removeHeader(String name) throws MessagingException {
|
1236 |
8
| headers.removeHeader(name);
|
1237 |
| } |
1238 |
| |
1239 |
| |
1240 |
| |
1241 |
| |
1242 |
| |
1243 |
| |
1244 |
| |
1245 |
0
| public Enumeration getAllHeaders() throws MessagingException {
|
1246 |
0
| return headers.getAllHeaders();
|
1247 |
| } |
1248 |
| |
1249 |
0
| public Enumeration getMatchingHeaders(String[] names) throws MessagingException {
|
1250 |
0
| return headers.getMatchingHeaders(names);
|
1251 |
| } |
1252 |
| |
1253 |
0
| public Enumeration getNonMatchingHeaders(String[] names) throws MessagingException {
|
1254 |
0
| return headers.getNonMatchingHeaders(names);
|
1255 |
| } |
1256 |
| |
1257 |
0
| public void addHeaderLine(String line) throws MessagingException {
|
1258 |
0
| headers.addHeaderLine(line);
|
1259 |
| } |
1260 |
| |
1261 |
0
| public Enumeration getAllHeaderLines() throws MessagingException {
|
1262 |
0
| return headers.getAllHeaderLines();
|
1263 |
| } |
1264 |
| |
1265 |
0
| public Enumeration getMatchingHeaderLines(String[] names) throws MessagingException {
|
1266 |
0
| return headers.getMatchingHeaderLines(names);
|
1267 |
| } |
1268 |
| |
1269 |
0
| public Enumeration getNonMatchingHeaderLines(String[] names) throws MessagingException {
|
1270 |
0
| return headers.getNonMatchingHeaderLines(names);
|
1271 |
| } |
1272 |
| |
1273 |
0
| public synchronized Flags getFlags() throws MessagingException {
|
1274 |
0
| return (Flags) flags.clone();
|
1275 |
| } |
1276 |
| |
1277 |
0
| public synchronized boolean isSet(Flags.Flag flag) throws MessagingException {
|
1278 |
0
| return flags.contains(flag);
|
1279 |
| } |
1280 |
| |
1281 |
| |
1282 |
| |
1283 |
| |
1284 |
| |
1285 |
| |
1286 |
| |
1287 |
| |
1288 |
| |
1289 |
0
| public synchronized void setFlags(Flags flag, boolean set) throws MessagingException {
|
1290 |
0
| if (set) {
|
1291 |
0
| flags.add(flag);
|
1292 |
| } |
1293 |
| else { |
1294 |
0
| flags.remove(flag);
|
1295 |
| } |
1296 |
| } |
1297 |
| |
1298 |
| |
1299 |
| |
1300 |
| |
1301 |
| |
1302 |
| |
1303 |
| |
1304 |
| |
1305 |
2
| public void saveChanges() throws MessagingException {
|
1306 |
| |
1307 |
2
| modified = true;
|
1308 |
2
| saved = true;
|
1309 |
| |
1310 |
2
| updateHeaders();
|
1311 |
| } |
1312 |
| |
1313 |
| |
1314 |
| |
1315 |
| |
1316 |
| |
1317 |
| |
1318 |
| |
1319 |
| |
1320 |
2
| protected void updateHeaders() throws MessagingException {
|
1321 |
| |
1322 |
| |
1323 |
2
| setHeader("MIME-Version", "1.0");
|
1324 |
| |
1325 |
2
| DataHandler handler = getDataHandler();
|
1326 |
| |
1327 |
2
| try {
|
1328 |
| |
1329 |
2
| String type = dh.getContentType();
|
1330 |
| |
1331 |
2
| ContentType content = new ContentType(type);
|
1332 |
| |
1333 |
| |
1334 |
2
| if (content.match("multipart/*")) {
|
1335 |
| |
1336 |
2
| try {
|
1337 |
2
| MimeMultipart part = (MimeMultipart)handler.getContent();
|
1338 |
2
| part.updateHeaders();
|
1339 |
| } catch (ClassCastException e) { |
1340 |
0
| throw new MessagingException("Message content is not MimeMultipart", e);
|
1341 |
| } |
1342 |
| } |
1343 |
0
| else if (!content.match("message/rfc822")) {
|
1344 |
| |
1345 |
| |
1346 |
0
| if (getSingleHeader("Content-Transfer-Encoding") == null) {
|
1347 |
0
| setHeader("Content-Transfer-Encoding", MimeUtility.getEncoding(handler));
|
1348 |
| } |
1349 |
| |
1350 |
| |
1351 |
0
| if (getSingleHeader("Content-Type") == null) {
|
1352 |
0
| if (SessionUtil.getBooleanProperty(session, "MIME_MAIL_SETDEFAULTTEXTCHARSET", true)) {
|
1353 |
| |
1354 |
0
| if (content.match("text/*")) {
|
1355 |
| |
1356 |
| |
1357 |
0
| if (content.getParameter("charset") == null) {
|
1358 |
| |
1359 |
0
| String encoding = getEncoding();
|
1360 |
| |
1361 |
| |
1362 |
0
| if (encoding != null && encoding.equalsIgnoreCase("7bit")) {
|
1363 |
0
| content.setParameter("charset", "us-ascii");
|
1364 |
| } |
1365 |
| else { |
1366 |
| |
1367 |
0
| content.setParameter("charset", MimeUtility.getDefaultMIMECharset());
|
1368 |
| } |
1369 |
| } |
1370 |
| } |
1371 |
| } |
1372 |
| } |
1373 |
| } |
1374 |
| |
1375 |
| |
1376 |
2
| if (getSingleHeader("Content-Type") == null) {
|
1377 |
| |
1378 |
| |
1379 |
1
| String disp = getSingleHeader("Content-Disposition");
|
1380 |
1
| if (disp != null) {
|
1381 |
| |
1382 |
0
| ContentDisposition disposition = new ContentDisposition(disp);
|
1383 |
| |
1384 |
0
| String filename = disposition.getParameter("filename");
|
1385 |
| |
1386 |
0
| if (filename != null) {
|
1387 |
0
| content.setParameter("name", filename);
|
1388 |
| } |
1389 |
| } |
1390 |
| |
1391 |
1
| setHeader("Content-Type", content.toString());
|
1392 |
| } |
1393 |
| |
1394 |
| } catch (IOException e) { |
1395 |
0
| throw new MessagingException("Error updating message headers", e);
|
1396 |
| } |
1397 |
| } |
1398 |
| |
1399 |
| |
1400 |
0
| protected InternetHeaders createInternetHeaders(InputStream in) throws MessagingException {
|
1401 |
| |
1402 |
0
| return new InternetHeaders(in);
|
1403 |
| } |
1404 |
| |
1405 |
| |
1406 |
| |
1407 |
| |
1408 |
| |
1409 |
| |
1410 |
| |
1411 |
| |
1412 |
| |
1413 |
14
| private Address[] getHeaderAsNewsAddresses(String header) throws MessagingException {
|
1414 |
| |
1415 |
| |
1416 |
14
| String mergedHeader = getHeader(header, ",");
|
1417 |
14
| if (mergedHeader != null) {
|
1418 |
9
| return NewsAddress.parse(mergedHeader);
|
1419 |
| } |
1420 |
5
| return null;
|
1421 |
| } |
1422 |
| |
1423 |
57
| private Address[] getHeaderAsInternetAddresses(String header, boolean strict) throws MessagingException {
|
1424 |
| |
1425 |
| |
1426 |
57
| String mergedHeader = getHeader(header, ",");
|
1427 |
57
| if (mergedHeader != null) {
|
1428 |
46
| return InternetAddress.parseHeader(mergedHeader, strict);
|
1429 |
| } |
1430 |
11
| return null;
|
1431 |
| } |
1432 |
| |
1433 |
| |
1434 |
| |
1435 |
| |
1436 |
| |
1437 |
| |
1438 |
| |
1439 |
| |
1440 |
55
| private boolean isStrictAddressing() {
|
1441 |
55
| return SessionUtil.getBooleanProperty(session, MIME_ADDRESS_STRICT, true);
|
1442 |
| } |
1443 |
| |
1444 |
| |
1445 |
| |
1446 |
| |
1447 |
| |
1448 |
| |
1449 |
| |
1450 |
| |
1451 |
| |
1452 |
7
| private void setHeader(String header, Address address) throws MessagingException {
|
1453 |
7
| if (address == null) {
|
1454 |
2
| removeHeader(header);
|
1455 |
| } |
1456 |
| else { |
1457 |
5
| setHeader(header, address.toString());
|
1458 |
| } |
1459 |
| } |
1460 |
| |
1461 |
| |
1462 |
| |
1463 |
| |
1464 |
| |
1465 |
| |
1466 |
| |
1467 |
| |
1468 |
16
| private void setHeader(String header, Address[] addresses) {
|
1469 |
16
| if (addresses == null) {
|
1470 |
5
| headers.removeHeader(header);
|
1471 |
| } |
1472 |
| else { |
1473 |
11
| headers.setHeader(header, addresses);
|
1474 |
| } |
1475 |
| } |
1476 |
| |
1477 |
8
| private void addHeader(String header, Address[] addresses) throws MessagingException {
|
1478 |
8
| headers.addHeader(header, InternetAddress.toString(addresses));
|
1479 |
| } |
1480 |
| |
1481 |
89
| private String getHeaderForRecipientType(Message.RecipientType type) throws MessagingException {
|
1482 |
89
| if (RecipientType.TO == type) {
|
1483 |
22
| return "To";
|
1484 |
67
| } else if (RecipientType.CC == type) {
|
1485 |
23
| return "Cc";
|
1486 |
44
| } else if (RecipientType.BCC == type) {
|
1487 |
22
| return "Bcc";
|
1488 |
22
| } else if (RecipientType.NEWSGROUPS == type) {
|
1489 |
22
| return "Newsgroups";
|
1490 |
| } else { |
1491 |
0
| throw new MessagingException("Unsupported recipient type: " + type.toString());
|
1492 |
| } |
1493 |
| } |
1494 |
| |
1495 |
| |
1496 |
| |
1497 |
| |
1498 |
| |
1499 |
| |
1500 |
| |
1501 |
| |
1502 |
| |
1503 |
| |
1504 |
| |
1505 |
19
| private String getSingleHeader(String name) throws MessagingException {
|
1506 |
19
| String[] values = getHeader(name);
|
1507 |
19
| if (values == null || values.length == 0) {
|
1508 |
8
| return null;
|
1509 |
| } else { |
1510 |
11
| return values[0];
|
1511 |
| } |
1512 |
| } |
1513 |
| } |