Class MailServer

All Implemented Interfaces:
Runnable, InitializingPhase, Named, ShutdownPhase, Endpoint, Server, ReferenceResolverAware

public class MailServer extends AbstractServer
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 Details

    • MailServer

      public MailServer()
  • Method Details

    • startup

      protected void startup()
      Specified by:
      startup in class AbstractServer
    • shutdown

      protected void shutdown()
      Specified by:
      shutdown in class AbstractServer
    • accept

      public boolean accept(String from, List<com.icegreen.greenmail.mail.MailAddress> recipients)
    • deliver

      public void deliver(jakarta.mail.internet.MimeMessage mimeMessage)
    • invokeEndpointAdapter

      protected Message invokeEndpointAdapter(MailMessage mail)
      Invokes the endpoint adapter with constructed mail message and headers.
    • getEndpointConfiguration

      public MailEndpointConfiguration getEndpointConfiguration()
      Specified by:
      getEndpointConfiguration in interface Endpoint
      Overrides:
      getEndpointConfiguration in class AbstractServer
    • getSession

      public jakarta.mail.Session getSession()
      Return a new mail session if not already created before.
    • isAuthRequired

      public boolean isAuthRequired()
      Users must authenticate properly with the server.
      Returns:
    • setAuthRequired

      public void setAuthRequired(boolean authRequired)
      Enable/disable the user authentication on this server.
      Parameters:
      authRequired -
    • isAutoAccept

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

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

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

      public void setMarshaller(MailMarshaller marshaller)
      Sets the mail message marshaller.
    • getJavaMailProperties

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

      public void setJavaMailProperties(Properties javaMailProperties)
      Sets the Java mail properties.
    • getPort

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

      public void setPort(int port)
      Sets the server port.
    • getSmtpServer

      public com.icegreen.greenmail.util.GreenMail getSmtpServer()
      Gets the smtp server instance.
    • setSmtpServer

      public void setSmtpServer(com.icegreen.greenmail.util.GreenMail smtpServer)
      Sets the smtp server instance.
    • isSplitMultipart

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

      public void setSplitMultipart(boolean splitMultipart)
      Sets the split multipart message.
    • getMessageConverter

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

      public void setMessageConverter(MailMessageConverter messageConverter)
      Sets the message converter.
    • getKnownUsers

      public List<String> getKnownUsers()
      Gets the known users.
      Returns:
    • setKnownUsers

      public void setKnownUsers(List<String> knownUsers)
      Sets the known users.
      Parameters:
      knownUsers -
    • addKnownUser

      public void addKnownUser(String email, String login, String password)
      Adds a new user known to this mail server.
      Parameters:
      email -
      login -
      password -