Class MailListener

java.lang.Object
com.nilhcem.fakesmtp.server.MailListener
All Implemented Interfaces:
org.subethamail.smtp.helper.SimpleMessageListener

public final class MailListener extends Object implements org.subethamail.smtp.helper.SimpleMessageListener
Listens to incoming emails and redirects them to the MailSaver object.
Since:
1.0
Author:
Nilhcem
  • Constructor Details

    • MailListener

      public MailListener(MailSaver saver)
      Creates the listener.
      Parameters:
      saver - a MailServer object used to save emails and notify components.
  • Method Details

    • accept

      public boolean accept(String from, String recipient)
      Accepts all kind of email (always return true).

      Called once for every RCPT TO during a SMTP exchange.
      Each accepted recipient will result in a separate deliver() call later.

      Specified by:
      accept in interface org.subethamail.smtp.helper.SimpleMessageListener
      Parameters:
      from - the user who send the email.
      recipient - the recipient of the email.
      Returns:
      always return true
    • deliver

      public void deliver(String from, String recipient, InputStream data) throws IOException
      Receives emails and forwards them to the MailSaver object.
      Specified by:
      deliver in interface org.subethamail.smtp.helper.SimpleMessageListener
      Throws:
      IOException