Custom IMAP processing

James allows defining your own handler packages.

An Imap package is a simple class that bundles IMAP processing components:

public interface ImapPackage {
    Collection<ClassName> processors();

    Collection<ClassName> decoders();

    Collection<ClassName> encoders();
}

Processors needs to be of class AbstractProcessor, decoders of class AbstractImapCommandParser and encoders of class ImapResponseEncoder. Extensions-jar mechanism can be used to load custom classes.

Custom configuration can be obtained through ImapConfiguration class via the getCustomProperties method.

A full working example is available here.

IMAP additional Connection Checks

James allows defining your own additional connection checks to guarantee that the connecting IP is secured.

A custom connection check should implement the following functional interface:

@FunctionalInterface
public interface ConnectionCheck {
    Publisher<Void> validate(InetSocketAddress remoteAddress);
}
  • validate method is used to check the connecting IP is secured.

Then the custom defined ConnectionCheck can be added in imapserver.xml file:

<additionalConnectionChecks>org.apache.james.CrowdsecImapConnectionCheck</additionalConnectionChecks>

An example for configuration is available here.