Class MailServer

  • All Implemented Interfaces:
    InitializingPhase, Named, ShutdownPhase, Endpoint, Server, com.consol.citrus.spi.ReferenceResolverAware, Runnable, org.subethamail.smtp.helper.SimpleMessageListener

    public class MailServer
    extends AbstractServer
    implements org.subethamail.smtp.helper.SimpleMessageListener
    Mail server implementation starts new SMTP server instance and listens for incoming mail messages. Incoming mail messages are converted to XML representation and forwarded to some message endpoint adapter (e.g. forwarding mail content to a message channel). By default incoming messages are accepted automatically. When auto accept is disabled the endpoint adapter is invoked with accept request and test case has to decide accept outcome in response. In case of incoming multipart mail messages the server is able to split the body parts into separate XML messages handled by the endpoint adapter.
    Since:
    1.4
    Author:
    Christoph Deppisch
    • Constructor Detail

      • MailServer

        public MailServer()
    • Method Detail

      • accept

        public boolean accept​(String from,
                              String recipient)
        Specified by:
        accept in interface org.subethamail.smtp.helper.SimpleMessageListener
      • deliver

        public void deliver​(String from,
                            String recipient,
                            InputStream data)
        Specified by:
        deliver in interface org.subethamail.smtp.helper.SimpleMessageListener
      • invokeEndpointAdapter

        protected Message invokeEndpointAdapter​(MailMessage mail)
        Invokes the endpoint adapter with constructed mail message and headers.
        Parameters:
        mail -
      • createMailMessage

        protected MailMessage createMailMessage​(Map<String,​Object> messageHeaders,
                                                String body,
                                                String contentType)
        Creates a new mail message model object from message headers.
        Parameters:
        messageHeaders -
        body -
        contentType -
        Returns:
      • getSession

        public javax.mail.Session getSession()
        Return new mail session if not already created before.
        Returns:
      • isAutoAccept

        public boolean isAutoAccept()
        Is auto accept enabled.
        Returns:
      • setAutoAccept

        public void setAutoAccept​(boolean autoAccept)
        Enable/disable auto accept feature.
        Parameters:
        autoAccept -
      • getMarshaller

        public MailMarshaller getMarshaller()
        Gets the mail message marshaller.
        Returns:
      • setMarshaller

        public void setMarshaller​(MailMarshaller marshaller)
        Sets the mail message marshaller.
        Parameters:
        marshaller -
      • getJavaMailProperties

        public Properties getJavaMailProperties()
        Gets the Java mail properties.
        Returns:
      • setJavaMailProperties

        public void setJavaMailProperties​(Properties javaMailProperties)
        Sets the Java mail properties.
        Parameters:
        javaMailProperties -
      • getPort

        public int getPort()
        Gets the server port.
        Returns:
      • setPort

        public void setPort​(int port)
        Sets the server port.
        Parameters:
        port -
      • getSmtpServer

        public org.subethamail.smtp.server.SMTPServer getSmtpServer()
        Gets the smtp server instance.
        Returns:
      • setSmtpServer

        public void setSmtpServer​(org.subethamail.smtp.server.SMTPServer smtpServer)
        Sets the smtp server instance.
        Parameters:
        smtpServer -
      • isSplitMultipart

        public boolean isSplitMultipart()
        Gets the split multipart message.
        Returns:
      • setSplitMultipart

        public void setSplitMultipart​(boolean splitMultipart)
        Sets the split multipart message.
        Parameters:
        splitMultipart -
      • getMessageConverter

        public MailMessageConverter getMessageConverter()
        Gets the message converter.
        Returns:
      • setMessageConverter

        public void setMessageConverter​(MailMessageConverter messageConverter)
        Sets the message converter.
        Parameters:
        messageConverter -