Manage Recipient Rewrite

To rewrite recipients, you need to create some "mappings".

You will rewrite any recipient to an existing or a non-existing server account.

So read "mapping allows to rewrite a 'fromAny(Existing/NotExisting) user and/or domain' to a 'toAny(Existing/NotExisting)Account'".

'An existing account' means an account defined in the Apache James Server.

You can also use regular expressions and wildcards (*) for the 'fromAny'.

The available methods exposed in the management interface are the following:

    /**
     * Add regex mapping
     * 
     * @param user
     *            the username. Null if no username should be used
     * @param domain
     *            the domain. Null if no domain should be used
     * @param regex
     *            the regex.
     */
    void addRegexMapping(String user, String domain, String regex) throws Exception;

    /**
     * Remove regex mapping
     * 
     * @param user
     *            the username. Null if no username should be used
     * @param domain
     *            the domain. Null if no domain should be used
     * @param regex
     *            the regex.
     */
    void removeRegexMapping(String user, String domain, String regex) throws Exception;

    /***
     * Add address mapping
     * 
     * @param user
     *            the username. Null if no username should be used
     * @param domain
     *            the domain. Null if no domain should be used
     * @param address
     *            the address.
     */
    void addAddressMapping(String user, String domain, String address) throws Exception;

    /**
     * Remove address mapping
     * 
     * @param user
     *            the username. Null if no username should be used
     * @param domain
     *            the domain. Null if no domain should be used
     * @param address
     */
    void removeAddressMapping(String user, String domain, String address) throws Exception;

    /**
     * Add error mapping
     * 
     * @param user
     *            the username. Null if no username should be used
     * @param domain
     *            the domain. Null if no domain should be used
     * @param error
     */
    void addErrorMapping(String user, String domain, String error) throws Exception;

    /**
     * Remove error mapping
     * 
     * @param user
     *            the username. Null if no username should be used
     * @param domain
     *            the domain. Null if no domain should be used
     * @param error
     * @return true if successfully
     */
    void removeErrorMapping(String user, String domain, String error) throws Exception;

    /**
     * Add domain mapping
     * 
     * @param domain
     *            the domain. Null if no domain should be used
     * @param targetDomain
     *            the target domain for the mapping
     * @return true if successfully
     */
    void addDomainMapping(String domain, String targetDomain) throws Exception;

    /**
     * Remove domain mapping
     * 
     * @param domain
     *            the domain. Null if no domain should be used
     * @param targetDomain
     *            the target domain for the mapping
     * 
     * @return true if successfully
     */
    void removeDomainMapping(String domain, String targetDomain) throws Exception;

    /**
     * Return the explicit mapping stored for the given user and domain. Return
     * null if no mapping was found
     * 
     * @param user
     *            the username
     * @param domain
     *            the domain
     * @return the collection which holds the mappings.
     */
    Collection<String> getUserDomainMappings(String user, String domain) throws Exception;

    /**
     * Try to identify the right method based on the prefix of the mapping and
     * add it.
     * 
     * @param user
     *            the username. Null if no username should be used
     * @param domain
     *            the domain. Null if no domain should be used
     * @param mapping
     *            the mapping.
     */
    void addMapping(String user, String domain, String mapping) throws Exception;

    /**
     * Try to identify the right method based on the prefix of the mapping and
     * remove it.
     * 
     * @param user
     *            the username. Null if no username should be used
     * @param domain
     *            the domain. Null if no domain should be used
     * @param mapping
     *            the mapping.
     */
    void removeMapping(String user, String domain, String mapping) throws Exception;

    /**
     * Return a Map which holds all mappings. The key is the user@domain and the
     * value is a Collection which holds all mappings
     * 
     * @return Map which holds all mappings
     */
    Map<String, Collection<String>> getAllMappings() throws Exception;
    

Manage Recipient Rewrite Table via Cli

Not available in this release.

Manage Virtual Users via JMX

Use and JMX client to access the Virtual User management function.

The managed objects are exposed from localhost only (for security reasons) on the following URL:

service:jmx:rmi:///jndi/rmi://localhost:9999/jmxrmi