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 private String defaultSubject = "[No Subject]";
50
51
52
53
54 private String from;
55
56
57
58
59 private Properties customHeaders = new Properties();
60
61 private String contentType = DEFAULT_CONTENT_TYPE;
62
63
64 public SmtpConnector()
65 {
66 this(DEFAULT_SMTP_PORT);
67 }
68
69 SmtpConnector(int defaultPort)
70 {
71 super(defaultPort, null);
72 }
73
74 public String getProtocol()
75 {
76 return "smtp";
77 }
78
79
80
81
82
83
84
85 public MessageReceiver createReceiver(Service service, InboundEndpoint endpoint) throws Exception
86 {
87 throw new UnsupportedOperationException("Listeners cannot be registered on a SMTP endpoint");
88 }
89
90
91
92
93 public String getFromAddress()
94 {
95 return from;
96 }
97
98
99
100
101 public String getBccAddresses()
102 {
103 return bcc;
104 }
105
106
107
108
109 public String getCcAddresses()
110 {
111 return cc;
112 }
113
114
115
116
117 public String getSubject()
118 {
119 return defaultSubject;
120 }
121
122 public void setBccAddresses(String string)
123 {
124 bcc = string;
125 }
126
127 public void setCcAddresses(String string)
128 {
129 cc = string;
130 }
131
132 public void setSubject(String string)
133 {
134 defaultSubject = string;
135 }
136
137 public void setFromAddress(String string)
138 {
139 from = string;
140 }
141
142 public String getReplyToAddresses()
143 {
144 return replyTo;
145 }
146
147 public void setReplyToAddresses(String replyTo)
148 {
149 this.replyTo = replyTo;
150 }
151
152 public Properties getCustomHeaders()
153 {
154 return customHeaders;
155 }
156
157 public void setCustomHeaders(Properties customHeaders)
158 {
159 this.customHeaders = customHeaders;
160 }
161
162 public String getContentType()
163 {
164 return contentType;
165 }
166
167 public void setContentType(String contentType)
168 {
169 this.contentType = contentType;
170 }
171
172 public int getDefaultPort()
173 {
174 return DEFAULT_SMTP_PORT;
175 }
176
177 }