Coverage Report - org.mule.transport.email.SmtpConnector
 
Classes in this File Line Coverage Branch Coverage Complexity
SmtpConnector
0%
0/31
N/A
1.053
 
 1  
 /*
 2  
  * $Id: SmtpConnector.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 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  
  * <code>SmtpConnector</code> is used to connect to and send data to an SMTP mail
 22  
  * server
 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  
      * Holds value of bcc addresses.
 34  
      */
 35  
     private String bcc;
 36  
 
 37  
     /**
 38  
      * Holds value of cc addresses.
 39  
      */
 40  
     private String cc;
 41  
 
 42  
     /**
 43  
      * Holds value of replyTo addresses.
 44  
      */
 45  
     private String replyTo;
 46  
 
 47  
     /**
 48  
      * Holds value of default subject
 49  
      */
 50  0
     private String defaultSubject = "[No Subject]";
 51  
 
 52  
     /**
 53  
      * Holds value of the from address.
 54  
      */
 55  
     private String from;
 56  
 
 57  
     /**
 58  
      * Any custom headers to be set on messages sent using this connector
 59  
      */
 60  0
     private Properties customHeaders = new Properties();
 61  
 
 62  0
     private String contentType = DEFAULT_CONTENT_TYPE;
 63  
 
 64  
     
 65  
     public SmtpConnector(MuleContext context)
 66  
     {
 67  0
         this(DEFAULT_SMTP_PORT, context);
 68  0
     }
 69  
     
 70  
     SmtpConnector(int defaultPort, MuleContext context)
 71  
     {
 72  0
         super(defaultPort, null, context);
 73  0
     }
 74  
     
 75  
     public String getProtocol()
 76  
     {
 77  0
         return "smtp";
 78  
     }
 79  
 
 80  
     public MessageReceiver createReceiver(FlowConstruct flowConstruct, InboundEndpoint endpoint) throws Exception
 81  
     {
 82  0
         throw new UnsupportedOperationException("Listeners cannot be registered on a SMTP endpoint");
 83  
     }
 84  
 
 85  
     /**
 86  
      * @return The default from address to use
 87  
      */
 88  
     public String getFromAddress()
 89  
     {
 90  0
         return from;
 91  
     }
 92  
 
 93  
     /**
 94  
      * @return the default comma separated list of BCC addresses to use
 95  
      */
 96  
     public String getBccAddresses()
 97  
     {
 98  0
         return bcc;
 99  
     }
 100  
 
 101  
     /**
 102  
      * @return the default comma separated list of CC addresses to use
 103  
      */
 104  
     public String getCcAddresses()
 105  
     {
 106  0
         return cc;
 107  
     }
 108  
 
 109  
     /**
 110  
      * @return the default message subject to use
 111  
      */
 112  
     public String getSubject()
 113  
     {
 114  0
         return defaultSubject;
 115  
     }
 116  
 
 117  
     public void setBccAddresses(String string)
 118  
     {
 119  0
         bcc = string;
 120  0
     }
 121  
 
 122  
     public void setCcAddresses(String string)
 123  
     {
 124  0
         cc = string;
 125  0
     }
 126  
 
 127  
     public void setSubject(String string)
 128  
     {
 129  0
         defaultSubject = string;
 130  0
     }
 131  
 
 132  
     public void setFromAddress(String string)
 133  
     {
 134  0
         from = string;
 135  0
     }
 136  
 
 137  
     public String getReplyToAddresses()
 138  
     {
 139  0
         return replyTo;
 140  
     }
 141  
 
 142  
     public void setReplyToAddresses(String replyTo)
 143  
     {
 144  0
         this.replyTo = replyTo;
 145  0
     }
 146  
 
 147  
     public Properties getCustomHeaders()
 148  
     {
 149  0
         return customHeaders;
 150  
     }
 151  
 
 152  
     public void setCustomHeaders(Properties customHeaders)
 153  
     {
 154  0
         this.customHeaders = customHeaders;
 155  0
     }
 156  
 
 157  
     public String getContentType()
 158  
     {
 159  0
         return contentType;
 160  
     }
 161  
 
 162  
     public void setContentType(String contentType)
 163  
     {
 164  0
         this.contentType = contentType;
 165  0
     }
 166  
 
 167  
     public int getDefaultPort()
 168  
     {
 169  0
         return DEFAULT_SMTP_PORT;
 170  
     }
 171  
 
 172  
 }