Kohei Nozaki's blog 

Entries tagged [james]

Configuring helo names of James

Posted on Friday Feb 06, 2015 at 04:47PM in Technology

My James instance looks like failed to determine its hostname as follows:

$ telnet localhost 10025
Connected to localhost.
Escape character is '^]'.
220 localhost.localdomain JAMES SMTP Server Server (JAMES SMTP Server ) ready
helo example.com
250 localhost.localdomain Hello example.com [])

This can be solved by editing XML files such as smtpserver.xml, pop3server.xml and imapserver.xml respectively as follows:

<helloName autodetect="false">www.nailedtothex.org</helloName>

Also you should check that the name which James will use during communicate to another SMTP server. you can check it easily with this site. if the name is wrong, this may be a cause of that remote server will consider your James server as spammer. the name to use will be hostname of the server. you can check it with simply issuing hostname command on Linux.

Unfortunately you can’t set the hostname in portable way due to a bug in a dependency geronimo-javamail_1.4_mail. the hostname should be able to configured in mailetcontainer.xml as follows but not worked at the present time.

<!-- Set the HELO/EHLO name to use when connectiong to remote SMTP-Server -->

So current geronimo-javamail_1.4_mail ignores that value. considerable solutions are following:

  1. Change the hostname of the server (for <= Java 7u51)

  2. Put you FQDN first (before localhost) in /etc/hosts. detail (for recent Java)

  3. Apply a patch to James

  4. Apply a patch to Geronimo JavaMail and update dependency of James. unfortunately seems like that fixed version of Geronimo JavaMail is not released yet.

Disabling SpamAssassin on James

Posted on Friday Feb 06, 2015 at 03:00PM in Technology

I’m using revision number 1657019 in the SVN trunk of James3. I see an error in james-server.log at every receiving of emails as follows:

INFO  14:41:51,912 | james.mailetcontext | Error communicating with spamd on localhost:783 Exception: java.net.ConnectException: Connection refused

It seems like that James is trying to connect to local SpamAssassin instance, but I have no SpamAssassin instance on my server yet so I simply deleted following definition from mailetcontainer.xml.

<mailet notmatch="SenderHostIsLocal" class="SpamAssassin">

Now the exception disappeared.

Defining aliases on James

Posted on Friday Feb 06, 2015 at 02:47PM in Technology

I’m using James3 in SVN trunk revision number 1657019.

Adding a user to recipient rewrite table

This forwards a address postmaster@example.com to kyle@example.com:

./james-cli.sh -p 9999 -h localhost addaddressmapping postmaster example.com kyle@example.com

Defining postmaster address

James replaces a particular address postmaster by PostmasterAlias according to XML definition on some environment, so we need to set correct email address to it. in $JAMES_HOME/mailetcontainer.xml as follows:

<mailetcontainer enableJmx="true">

    <!-- MailAddress used for PostMaster -->

Updating and Configuring Derby shipped with James

Posted on Friday Feb 06, 2015 at 02:30PM in Technology

Put latest Derby jars

I used derby.jar and derbynet.jar of to accept network connections. put these jars you needed into $JAMES_HOME/lib.

Define that jars to wrapper.conf

Comment out following line in $JAMES_HOME/conf/wrapper.conf:


Then put following line:


Make Derby to accept network connections

Add following line to $JAMES_HOME/conf/wrapper.conf.


Also additional system properties are needed:


Config derby.log

I prefer to place derby.log into $JAMES_HOME/log, and append log to exist one.


Define shutdown hook of Derby

Lob streaming is not supported

Currently OpenJPA, James’s JPA provider, is not supported lob streaming for Derby. James stored mail data in lob so If you frequently use larger mails, consider using other databases instead of Derby.

Installing James as a service of CentOS

Posted on Thursday Feb 05, 2015 at 05:16PM in Technology

In previous posting, I set up James as a plain standalone application on OS X. this time I’m going to install James as a service on CentOS 6.6, and expose its SMTP, POP3 and IMAP ports to external network.

Create a user for James

The java process of James will run james user which added in this step.

sudo useradd james

Extract tarball

I’ll use james-server-app-3.0.0-beta5-SNAPSHOT-app.tar.gz which built in previous posting.

sudo tar zxvf james-server-app-3.0.0-beta5-SNAPSHOT-app.tar.gz -C /usr/local --no-same-owner
sudo chown -R james:james /usr/local/james-server-app-3.0.0-beta5-SNAPSHOT
sudo ln -s /usr/local/james-server-app-3.0.0-beta5-SNAPSHOT /usr/local/james

Change ports that James will listen

Add offset of 10000 to bind element in smtpserver.xml, pop3server.xml and imapserver.xml respectively as I did in previous posting.

Reduce heap size

Default maximum heap size of James is 512MB but it’s too large for me because I have only small amount of memory on the server so I reduced it to more smaller. this can be done with modifying the file $JAMES_HOME/conf/wrapper.conf as follows:


Define user to startup script

In $JAMES_HOME/bin/james there’s a variable which defines the user to run the process of James. so set it to james as follows:


Register the startup script

sudo ln -s /usr/local/james/bin/james /etc/init.d
sudo chkconfig --add james
sudo chkconfig james on

Now we can control James with service command as follows:

sudo service james start
sudo service james stop

Also James will be launched / shutdown automatically at every boot/shutdown process of CentOS.

NOTE on some environment, following error may occur.

$ sudo service james start
Starting Apache James :: Server :: App...
/usr/local/james-server-app-3.0.0-beta5-SNAPSHOT/bin/james: /usr/local/james-server-app-3.0.0-beta5-SNAPSHOT/bin/./wrapper-linux-x86-32: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

According to this discussion, it related to the environment which used in build. then the problem should be fixed with issuing following command:

sudo yum install glibc.i686

Configure port forwarding

This makes SMTP, POP3 and IMAP ports to be forwarded to ports of James listening. this enables us to launch James process as a regular user owning process, not root process. here’s an example of /etc/sysconfig/iptables:

-A PREROUTING -i eth0 -p tcp --dport 25 -j DNAT --to-destination :10025
-A PREROUTING -i eth0 -p tcp --dport 110 -j DNAT --to-destination :10110
-A PREROUTING -i eth0 -p tcp --dport 143 -j DNAT --to-destination :10143
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10025 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10110 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10143 -j ACCEPT

After update the /etc/sysconfig/iptables file, restart the iptables serivce as follows:

sudo service iptables restart

Remaining tasks such as registering shutdown hook of Derby, creating domains, users…​

NOTE: You should make James to use secured connection

Currently all of communication between the server and client is clear text so any data including credentials can be sniffed. I would try to configure James to use secured connection in another post later.