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