001: /*
002: * $Id: SmtpConnector.java 11110 2008-02-28 13:55:36Z acooke $
003: * --------------------------------------------------------------------------------------
004: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
005: *
006: * The software in this package is published under the terms of the CPAL v1.0
007: * license, a copy of which has been included with this distribution in the
008: * LICENSE.txt file.
009: */
010:
011: package org.mule.transport.email;
012:
013: import org.mule.api.endpoint.InboundEndpoint;
014: import org.mule.api.service.Service;
015: import org.mule.api.transport.MessageReceiver;
016:
017: import java.util.Properties;
018:
019: /**
020: * <code>SmtpConnector</code> is used to connect to and send data to an SMTP mail
021: * server
022: */
023: public class SmtpConnector extends AbstractMailConnector {
024:
025: public static final String SMTP = "smtp";
026: public static final String DEFAULT_SMTP_HOST = "localhost";
027: public static final int DEFAULT_SMTP_PORT = 25;
028: public static final String DEFAULT_CONTENT_TYPE = "text/plain";
029:
030: /**
031: * Holds value of bcc addresses.
032: */
033: private String bcc;
034:
035: /**
036: * Holds value of cc addresses.
037: */
038: private String cc;
039:
040: /**
041: * Holds value of replyTo addresses.
042: */
043: private String replyTo;
044:
045: /**
046: * Holds value of default subject
047: */
048: private String defaultSubject = "[No Subject]";
049:
050: /**
051: * Holds value of the from address.
052: */
053: private String from;
054:
055: /**
056: * Any custom headers to be set on messages sent using this connector
057: */
058: private Properties customHeaders = new Properties();
059:
060: private String contentType = DEFAULT_CONTENT_TYPE;
061:
062: public SmtpConnector() {
063: this (DEFAULT_SMTP_PORT);
064: }
065:
066: SmtpConnector(int defaultPort) {
067: super (defaultPort, null);
068: }
069:
070: public String getProtocol() {
071: return "smtp";
072: }
073:
074: /*
075: * (non-Javadoc)
076: *
077: * @see org.mule.transport.UMOConnector#registerListener(javax.jms.MessageListener,
078: * java.lang.String)
079: */
080: public MessageReceiver createReceiver(Service service,
081: InboundEndpoint endpoint) throws Exception {
082: throw new UnsupportedOperationException(
083: "Listeners cannot be registered on a SMTP endpoint");
084: }
085:
086: /**
087: * @return The default from address to use
088: */
089: public String getFromAddress() {
090: return from;
091: }
092:
093: /**
094: * @return the default comma separated list of BCC addresses to use
095: */
096: public String getBccAddresses() {
097: return bcc;
098: }
099:
100: /**
101: * @return the default comma separated list of CC addresses to use
102: */
103: public String getCcAddresses() {
104: return cc;
105: }
106:
107: /**
108: * @return the default message subject to use
109: */
110: public String getSubject() {
111: return defaultSubject;
112: }
113:
114: public void setBccAddresses(String string) {
115: bcc = string;
116: }
117:
118: public void setCcAddresses(String string) {
119: cc = string;
120: }
121:
122: public void setSubject(String string) {
123: defaultSubject = string;
124: }
125:
126: public void setFromAddress(String string) {
127: from = string;
128: }
129:
130: public String getReplyToAddresses() {
131: return replyTo;
132: }
133:
134: public void setReplyToAddresses(String replyTo) {
135: this .replyTo = replyTo;
136: }
137:
138: public Properties getCustomHeaders() {
139: return customHeaders;
140: }
141:
142: public void setCustomHeaders(Properties customHeaders) {
143: this .customHeaders = customHeaders;
144: }
145:
146: public String getContentType() {
147: return contentType;
148: }
149:
150: public void setContentType(String contentType) {
151: this .contentType = contentType;
152: }
153:
154: public int getDefaultPort() {
155: return DEFAULT_SMTP_PORT;
156: }
157:
158: }
|