Apache James
A customizable e-mail server solution

In today's society, it's second nature to contact family, friends, and colleagues via e-mail. E-mail has become so integral to our daily ritual that we cannot stay away from it as we make use of personal digital assistants (PDAs) and other pervasive devices to have it readily available. How do these billions of digital messages get to users across the globe?

A client/server setup is required to participate in the exchange of e-mails. It was just a few years ago that expensive server software packages were used for the typical e-mail solution. Cheaper solutions have been plagued by a lack of robustness and scalability. To the avail of shrinking corporate budgets comes the Java Apache Mail Enterprise Server (known as Apache James).

Apache James is a free, open source, robust offering from the Apache Software Foundation that aims to provide enterprises with a Java-based mail server solution. James provides a Java API for developers to process e-mail services. In this article, we'll explore James and what it can offer your enterprise operation.

Understanding E-Mail
In the world of e-mail, the senders and recipients of messages act as clients to e-mail servers. Senders create an e-mail using a Mail User Agent (MUA) and transmit the message to an e-mail server using the Simple Mail Transfer Protocol (SMTP). The e-mail server uses the same protocol to contact the recipient's e-mail server. Recipients then use the Post Office Protocol (POP3) or alternatively the Internet Message Access Protocol (IMAP) to retrieve the message from their e-mail server. Note: IMAP support is currently experimental in James 2.1.3.

As mentioned, e-mail servers use SMTP to transmit messages across the world. The default TCP port for this protocol is 25. Accordingly, network administrators need to configure firewalls for access to the SMTP port.

POP3 is used to retrieve messages from the e-mail server. The default TCP port for this protocol is 110. Clients must provide security information used for authentication with the e-mail server. Upon successful authentication, clients can access their messages from their respective mailboxes.

Getting Hold of James
The software is available for download from the Apache James homepage at http://james.apache.org/. James was in version 2.1.3 at the time of this writing; this version requires Java 2 (Java Runtime Environment version 1.3 or 1.4 as of 2.0a3).

Firing Up James
Before you begin, ensure that the system environment variable, JAVA_HOME, points to the JRE 1.3+ home directory. To fire up James, simply navigate to the bin directory created upon extracting the contents of the downloaded archive file. In this directory, locate and execute the "run.bat" script. Upon running the script, a confirmation will be displayed that James is listening on ports 25 (SMTP) and 110 (POP3) (see Figure 1).


The configuration files are unpacked the first time James runs. At this point stop the server, make the necessary configuration changes, and restart the server for the modifications to take effect. A needed modification is in the config.xml file located in the <james-installdir>\apps\james\ SAR-INF directory.

<servernames autodetect="true" autodetectIP="true">
<!-- CONFIRM? -->

Add the Domain Name Service (DNS) namespace you want served by James. For example, to have James provide e-mail services for somedomain.com, the configuration would look like the following:

<servernames autodetect="true" autodetectIP="true">
<!-- CONFIRM? -->

Note: The assumption is that the necessary upstream configurations are in place for the DNS and Mail Exchanger (MX) records.

Administering James
Remote administration to the James server is available through Telnet. The "Remote Manager Service" listens on port 4555 by default. Access this service using the following command:

telnet localhost 4555

Replace "localhost" in the above code with the appropriate host name or IP address. The default login/password for the Remote Manager Service is root/root. To alter this information, edit the config.xml file located in the <james-installdir>\apps\ james\SAR-INF directory. Look for the following section:

<!-- CHECKME! -->
<!-- Change the default login/password. -->
<account login="root" password="root"/>

The Remote Manager Service provides the user with an easily accessible help facility through the command HELP.

Now, begin administration of the e-mail server by adding user mailboxes. This is accomplished by issuing the following command:

adduser [username] [password]

For this exercise, we added two users, kulvir and kwang, with the same password of security.

adduser kulvir security
adduser kwang security

As shown in Figure 2, James will not echo the process of you creating the user.


Sending and Receiving Some Mail
At this point, e-mail clients such as Lotus Notes and Microsoft Outlook should be able send and receive messages from the e-mail accounts just created. Consult your product documentation regarding proper account configuration for your client of choice.

The Mailet API
Similar to Java servlets running on an application server, the Apache Software Foundation allows James to act as a container that can run mailets that extend the capabilities of the mail server. Mailets are Java applications, developed using the mailet API, that perform various mail-processing tasks including auto-response engines, spam filters, and e-mail indexing. The mailet API, along with sample mailets, is bundled with the James distribution.

For our exercise, we will enable "AddFooter", a prepackaged mailet. First, modify the "config.xml" file by adding the code in Listing 1. Let's discuss two important attributes of the mailet tag. The class attribute refers to the mailet's Java class. The match attribute refers to the matcher, a Java class that implements the Matcher API. Matchers return a collection of recipients that satisfy the defined conditions. There are a number of matchers prebundled with the James distribution. The "All" matcher returns all recipients for all messages processed by a mailet.

James registers mailets during initial startup. Restart the server to enable the newly defined mailet. Send an e-mail to one of your registered accounts. The recipient should see the specified footer text added to the end of a message sent to him or her (see Figure 3).


The power of James lies in its ability to extend its capabilities through custom mailets and matchers. Using the APIs provided by the Apache Software Foundation, you can create your own setups to process mail, satisfying virtually any business requirement required of a mail server. The James Web site has a good amount of documentation about how to go about creating your own mailets and matchers.

Mailing Lists
James also supports mailing lists that allow individuals to subscribe/unsubscribe to topics. It's simple to configure and use. For more information regarding the James mailing list feature, view the James FAQ documentation.

Contributing to James
Like other Apache open source projects, James relies on the programming community to contribute code enhancements to yield a more powerful and stable application. It's this collaborative effort that has led to what we see in James today. You can learn more about contributing to James at http://james.apache.org/contribute.html.

As this article illustrated, James is simple to configure and run. Coupled with the power to design customer matchers and mailets, it represents a highly user-friendly, extensible e-mail server solution, customizable to fit your enterprise needs.

About Kulvir Singh Bhogal
Kulvir Singh Bhogal works as an IBM Software Services for WebSphere consultant, devising and implementing WebSphere-centric solutions at customer sites across the nation. He has over fifty patents pending in a myriad of technology areas. He can be reached at kbhogal@us.ibm.com

About Kwang Kang

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

HI Sir,
I am suneel and i am using james server james-MailetSDK-2.2.1-RC1.zip product
and i am unable to fetch out the attachment from the james server by using java mail API. It is showing the error NoSuchProviderException . please send me the solution for this.
Thank you very much

Hi Sir,