1
2
3
4
5
6
7
8
9
10
11 package org.mule.providers.email;
12
13 import org.mule.umo.UMOComponent;
14 import org.mule.umo.lifecycle.InitialisationException;
15 import org.mule.umo.endpoint.UMOEndpoint;
16 import org.mule.umo.provider.UMOMessageReceiver;
17
18 import java.util.Properties;
19
20
21
22
23
24 public class SmtpConnector extends AbstractMailConnector
25 {
26 public static final String DEFAULT_SMTP_HOST = "localhost";
27 public static final int DEFAULT_SMTP_PORT = 25;
28 public static final String DEFAULT_CONTENT_TYPE = "text/plain";
29
30 private String host = DEFAULT_SMTP_HOST;
31 private int port = DEFAULT_SMTP_PORT;
32 private String username;
33 private String password;
34
35
36
37
38 private String bcc;
39
40
41
42
43 private String cc;
44
45
46
47
48 private String replyTo;
49
50
51
52
53 private String defaultSubject = "[No Subject]";
54
55
56
57
58 private String from;
59
60
61
62
63 private Properties customHeaders = new Properties();
64
65 private String contentType = DEFAULT_CONTENT_TYPE;
66
67
68 public SmtpConnector()
69 {
70 this(DEFAULT_SMTP_PORT);
71 }
72
73 SmtpConnector(int defaultPort)
74 {
75 super(defaultPort, null);
76 }
77
78 public String getProtocol()
79 {
80 return "smtp";
81 }
82
83
84 protected void doInitialise() throws InitialisationException
85 {
86
87
88 if(getFromAddress()==null && getUsername()!=null && getUsername().indexOf('@') > -1)
89 {
90 setFromAddress(getUsername());
91 }
92 }
93
94
95
96
97
98
99
100 public UMOMessageReceiver createReceiver(UMOComponent component, UMOEndpoint endpoint) throws Exception
101 {
102 throw new UnsupportedOperationException("Listeners cannot be registered on a SMTP endpoint");
103 }
104
105
106
107
108 public String getFromAddress()
109 {
110 return from;
111 }
112
113
114
115
116 public String getBccAddresses()
117 {
118 return bcc;
119 }
120
121
122
123
124 public String getCcAddresses()
125 {
126 return cc;
127 }
128
129
130
131
132 public String getSubject()
133 {
134 return defaultSubject;
135 }
136
137 public void setBccAddresses(String string)
138 {
139 bcc = string;
140 }
141
142 public void setCcAddresses(String string)
143 {
144 cc = string;
145 }
146
147 public void setSubject(String string)
148 {
149 defaultSubject = string;
150 }
151
152 public void setFromAddress(String string)
153 {
154 from = string;
155 }
156
157 public String getReplyToAddresses()
158 {
159 return replyTo;
160 }
161
162 public void setReplyToAddresses(String replyTo)
163 {
164 this.replyTo = replyTo;
165 }
166
167 public Properties getCustomHeaders()
168 {
169 return customHeaders;
170 }
171
172 public void setCustomHeaders(Properties customHeaders)
173 {
174 this.customHeaders = customHeaders;
175 }
176
177 public String getContentType()
178 {
179 return contentType;
180 }
181
182 public void setContentType(String contentType)
183 {
184 this.contentType = contentType;
185 }
186
187 public int getDefaultPort()
188 {
189 return DEFAULT_SMTP_PORT;
190 }
191
192 public String getHost()
193 {
194 return host;
195 }
196
197 public void setHost(String host)
198 {
199 this.host = host;
200 }
201
202 public String getPassword()
203 {
204 return password;
205 }
206
207 public void setPassword(String password)
208 {
209 this.password = password;
210 }
211
212 public int getPort()
213 {
214 return port;
215 }
216
217 public void setPort(int port)
218 {
219 this.port = port;
220 }
221
222 public String getUsername()
223 {
224 return username;
225 }
226
227 public void setUsername(String username)
228 {
229 this.username = username;
230 }
231
232 }