1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.transport.email; |
12 | |
|
13 | |
import org.mule.api.endpoint.InboundEndpoint; |
14 | |
import org.mule.api.service.Service; |
15 | |
import org.mule.api.transport.MessageReceiver; |
16 | |
|
17 | |
import java.util.Properties; |
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
public class SmtpConnector extends AbstractMailConnector |
24 | |
{ |
25 | |
|
26 | |
public static final String SMTP = "smtp"; |
27 | |
public static final String DEFAULT_SMTP_HOST = "localhost"; |
28 | |
public static final int DEFAULT_SMTP_PORT = 25; |
29 | |
public static final String DEFAULT_CONTENT_TYPE = "text/plain"; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
private String bcc; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
private String cc; |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
private String replyTo; |
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | 74 | private String defaultSubject = "[No Subject]"; |
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
private String from; |
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | 74 | private Properties customHeaders = new Properties(); |
60 | |
|
61 | 74 | private String contentType = DEFAULT_CONTENT_TYPE; |
62 | |
|
63 | |
|
64 | |
public SmtpConnector() |
65 | |
{ |
66 | 44 | this(DEFAULT_SMTP_PORT); |
67 | 44 | } |
68 | |
|
69 | |
SmtpConnector(int defaultPort) |
70 | |
{ |
71 | 74 | super(defaultPort, null); |
72 | 74 | } |
73 | |
|
74 | |
public String getProtocol() |
75 | |
{ |
76 | 208 | return "smtp"; |
77 | |
} |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
public MessageReceiver createReceiver(Service service, InboundEndpoint endpoint) throws Exception |
86 | |
{ |
87 | 4 | throw new UnsupportedOperationException("Listeners cannot be registered on a SMTP endpoint"); |
88 | |
} |
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
public String getFromAddress() |
94 | |
{ |
95 | 18 | return from; |
96 | |
} |
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
public String getBccAddresses() |
102 | |
{ |
103 | 18 | return bcc; |
104 | |
} |
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
public String getCcAddresses() |
110 | |
{ |
111 | 18 | return cc; |
112 | |
} |
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
public String getSubject() |
118 | |
{ |
119 | 18 | return defaultSubject; |
120 | |
} |
121 | |
|
122 | |
public void setBccAddresses(String string) |
123 | |
{ |
124 | 12 | bcc = string; |
125 | 12 | } |
126 | |
|
127 | |
public void setCcAddresses(String string) |
128 | |
{ |
129 | 12 | cc = string; |
130 | 12 | } |
131 | |
|
132 | |
public void setSubject(String string) |
133 | |
{ |
134 | 12 | defaultSubject = string; |
135 | 12 | } |
136 | |
|
137 | |
public void setFromAddress(String string) |
138 | |
{ |
139 | 12 | from = string; |
140 | 12 | } |
141 | |
|
142 | |
public String getReplyToAddresses() |
143 | |
{ |
144 | 18 | return replyTo; |
145 | |
} |
146 | |
|
147 | |
public void setReplyToAddresses(String replyTo) |
148 | |
{ |
149 | 12 | this.replyTo = replyTo; |
150 | 12 | } |
151 | |
|
152 | |
public Properties getCustomHeaders() |
153 | |
{ |
154 | 18 | return customHeaders; |
155 | |
} |
156 | |
|
157 | |
public void setCustomHeaders(Properties customHeaders) |
158 | |
{ |
159 | 12 | this.customHeaders = customHeaders; |
160 | 12 | } |
161 | |
|
162 | |
public String getContentType() |
163 | |
{ |
164 | 18 | return contentType; |
165 | |
} |
166 | |
|
167 | |
public void setContentType(String contentType) |
168 | |
{ |
169 | 12 | this.contentType = contentType; |
170 | 12 | } |
171 | |
|
172 | |
public int getDefaultPort() |
173 | |
{ |
174 | 8 | return DEFAULT_SMTP_PORT; |
175 | |
} |
176 | |
|
177 | |
} |