1 10 11 package org.mule.providers.email; 12 13 import java.util.Properties ; 14 15 import javax.mail.Authenticator ; 16 17 import org.mule.providers.AbstractServiceEnabledConnector; 18 import org.mule.umo.UMOComponent; 19 import org.mule.umo.UMOException; 20 import org.mule.umo.endpoint.UMOEndpoint; 21 import org.mule.umo.lifecycle.InitialisationException; 22 import org.mule.umo.provider.UMOMessageReceiver; 23 24 28 public class SmtpConnector extends AbstractServiceEnabledConnector implements MailConnector 29 { 30 public static final String DEFAULT_SMTP_HOST = "localhost"; 31 public static final int DEFAULT_SMTP_PORT = 25; 32 public static final String DEFAULT_CONTENT_TYPE = "text/plain"; 33 34 private String host = DEFAULT_SMTP_HOST; 35 private int port = DEFAULT_SMTP_PORT; 36 private String username; 37 private String password; 38 39 42 private String bcc; 43 44 47 private String cc; 48 49 52 private String replyTo; 53 54 57 private String defaultSubject = "[No Subject]"; 58 59 62 private String from; 63 64 67 private Properties customHeaders = new Properties (); 68 69 74 private Authenticator authenticator = null; 75 76 private String contentType = DEFAULT_CONTENT_TYPE; 77 78 public SmtpConnector() throws InitialisationException 79 { 80 initFromServiceDescriptor(); 81 } 82 83 89 public UMOMessageReceiver createReceiver(UMOComponent component, UMOEndpoint endpoint) throws Exception 90 { 91 throw new UnsupportedOperationException ("Listeners cannot be registered on a SMTP endpoint"); 92 } 93 94 97 public void doStart() throws UMOException 98 { 99 } 101 102 107 public void doStop() throws UMOException 108 { 109 } 111 112 117 protected void doDispose() 118 { 119 try 120 { 121 doStop(); 122 } 123 catch (UMOException e) 124 { 125 logger.error(e.getMessage(), e); 126 } 127 } 128 129 public String getProtocol() 130 { 131 return "smtp"; 132 } 133 134 138 141 public String getFromAddress() 142 { 143 return from; 144 } 145 146 149 public String getBccAddresses() 150 { 151 return bcc; 152 } 153 154 157 public String getCcAddresses() 158 { 159 return cc; 160 } 161 162 165 public String getSubject() 166 { 167 return defaultSubject; 168 } 169 170 public void setBccAddresses(String string) 171 { 172 bcc = string; 173 } 174 175 public void setCcAddresses(String string) 176 { 177 cc = string; 178 } 179 180 public void setSubject(String string) 181 { 182 defaultSubject = string; 183 } 184 185 public void setFromAddress(String string) 186 { 187 from = string; 188 } 189 190 public String getReplyToAddresses() 191 { 192 return replyTo; 193 } 194 195 public void setReplyToAddresses(String replyTo) 196 { 197 this.replyTo = replyTo; 198 } 199 200 public Properties getCustomHeaders() 201 { 202 return customHeaders; 203 } 204 205 public void setCustomHeaders(Properties customHeaders) 206 { 207 this.customHeaders = customHeaders; 208 } 209 210 public Authenticator getAuthenticator() 211 { 212 return authenticator; 213 } 214 215 public void setAuthenticator(Authenticator authenticator) 216 { 217 this.authenticator = authenticator; 218 } 219 220 public String getContentType() 221 { 222 return contentType; 223 } 224 225 public void setContentType(String contentType) 226 { 227 this.contentType = contentType; 228 } 229 230 public int getDefaultPort() 231 { 232 return DEFAULT_SMTP_PORT; 233 } 234 235 public String getHost() 236 { 237 return host; 238 } 239 240 public void setHost(String host) 241 { 242 this.host = host; 243 } 244 245 public String getPassword() 246 { 247 return password; 248 } 249 250 public void setPassword(String password) 251 { 252 this.password = password; 253 } 254 255 public int getPort() 256 { 257 return port; 258 } 259 260 public void setPort(int port) 261 { 262 this.port = port; 263 } 264 265 public String getUsername() 266 { 267 return username; 268 } 269 270 public void setUsername(String username) 271 { 272 this.username = username; 273 } 274 } 275 | Popular Tags |