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