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