%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.util.mail.SimpleEmail |
|
|
1 | package org.apache.turbine.util.mail; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2005 The Apache Software Foundation. |
|
5 | * |
|
6 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
7 | * you may not use this file except in compliance with the License. |
|
8 | * 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, software |
|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | * See the License for the specific language governing permissions and |
|
16 | * limitations under the License. |
|
17 | */ |
|
18 | ||
19 | import javax.mail.MessagingException; |
|
20 | ||
21 | import org.apache.torque.util.Criteria; |
|
22 | ||
23 | /** |
|
24 | * This class is used to send simple internet email messages without |
|
25 | * attachments. |
|
26 | * |
|
27 | * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a> |
|
28 | * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a> |
|
29 | * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a> |
|
30 | * @author <a href="mailto:unknown">Regis Koenig</a> |
|
31 | * @version $Id: SimpleEmail.java 264148 2005-08-29 14:21:04Z henning $ |
|
32 | * @deprecated Use org.apache.commons.mail.SimpleEmail instead. |
|
33 | */ |
|
34 | public class SimpleEmail |
|
35 | extends Email |
|
36 | { |
|
37 | /** the conentet type for body of the message */ |
|
38 | 0 | private String contentType = null; |
39 | ||
40 | /** |
|
41 | * Default constructor. |
|
42 | * |
|
43 | * @exception MessagingException. |
|
44 | */ |
|
45 | public SimpleEmail() throws MessagingException |
|
46 | 0 | { |
47 | 0 | super.init(); |
48 | 0 | } |
49 | ||
50 | /** |
|
51 | * Constructor used to initialize attributes. To create a simple |
|
52 | * email you need to pass a Criteria object into the SimpleEmail |
|
53 | * constructor which contains: |
|
54 | * |
|
55 | * <ul> |
|
56 | * <li>SENDER_EMAIL</li> |
|
57 | * <li>SENDER_NAME</li> |
|
58 | * <li>RECEIVER_EMAIL</li> |
|
59 | * <li>RECEIVER_NAME</li> |
|
60 | * <li>EMAIL_SUBJECT</li> |
|
61 | * <li>EMAIL_BODY</li> |
|
62 | * </ul> |
|
63 | * |
|
64 | * Deprecated, since Criteria is deprecated in mail API. |
|
65 | * |
|
66 | * @param criteria A Criteria. |
|
67 | * @exception MessagingException. |
|
68 | */ |
|
69 | public SimpleEmail(Criteria criteria) |
|
70 | throws MessagingException |
|
71 | 0 | { |
72 | 0 | super.init(); |
73 | 0 | this.initCriteria(criteria); |
74 | 0 | } |
75 | ||
76 | /** |
|
77 | * Uses the criteria to set the fields. |
|
78 | * |
|
79 | * Deprecated, since the Criteria is deprecated. |
|
80 | * |
|
81 | * @param criteria A Criteria. |
|
82 | * @exception MessagingException. |
|
83 | */ |
|
84 | protected void initCriteria(Criteria criteria) |
|
85 | throws MessagingException |
|
86 | { |
|
87 | 0 | super.initCriteria(criteria); |
88 | ||
89 | 0 | if (criteria.containsKey(CONTENT_TYPE)) |
90 | { |
|
91 | 0 | contentType = criteria.getString(CONTENT_TYPE); |
92 | } |
|
93 | ||
94 | 0 | if (criteria.containsKey(EMAIL_BODY)) |
95 | { |
|
96 | 0 | setMsg(criteria.getString(EMAIL_BODY)); |
97 | } |
|
98 | else |
|
99 | { |
|
100 | 0 | setMsg("NO MESSAGE"); |
101 | } |
|
102 | 0 | } |
103 | ||
104 | /** |
|
105 | * Set the content of the mail |
|
106 | * |
|
107 | * @param msg A String. |
|
108 | * @return An Email. |
|
109 | * @exception MessagingException. |
|
110 | */ |
|
111 | public Email setMsg(String msg) throws MessagingException |
|
112 | { |
|
113 | 0 | if (contentType == null) |
114 | { |
|
115 | 0 | contentType = TEXT_PLAIN; |
116 | } |
|
117 | 0 | message.setContent(msg, contentType); |
118 | 0 | return this; |
119 | } |
|
120 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |