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