I do development and sometimes I have to recreate issues with actual data which means using other people's email addresses. Obviously I don't want to send them email while i'm testing so I use Apache James as a local only email server.

Here are the steps i use to set this up.

Download and Run James Server

From http://james.apache.org/download.cgi or directly from http://mirror.nyi.net/apache//james/server/apache-james-2.3.2.zip and extract to a folder.

As i'm running a mac, I added the following to run.sh. If you're on a windows machine, this step may not be required.

Start the server…

On a mac

bin/run.sh

On windows

bin/run.bat

Create a local email account

    $ telnet localhost 4555
    Trying ::1...
    telnet: connect to address ::1: Connection refused
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    JAMES Remote Administration Tool 2.3.2
    Please enter your login and password
    Login id:
    root
    Password:
    root
    adduser me me
    User me added

Remove the Remote Delivery Mailet

Remove ( or comment out ) the Remote Delivery mailet in <james_home>/apps/james/SAR-INF/config.xml . Open the file and search on 'class=”RemoteDelivery”', and comment out the whole stanza.

Forward all email to the local account

Important

It's very important that you configure the forwarding mailet to be in the same place where the RemoteDelivery mailet was. If you put it too early in the config.xml you may get errors when it attempts to forward a message.

Insert the following mailet in the place where the RemoteDelivery mailet was previously located in ( <james_home>/apps/james/SAR-INF/config.xml ).

Run the Server

Save your changes in the config.xml file and start the server.

On a mac

sudo bin/run.sh

On windows

bin/run.bat

Test the Mail Server

Send an email to me@localhost and use a POP client to 'get' the email. You should see it.
Send an email to anywhere@anywhere.net and retrieve the message, it should be redirected to your local inbox.


Install Mutt

On a mac I use homebrew ( http://mxcl.github.com/homebrew/ ), and simply run:

brew install mutt

Configure Mutt

Run Mutt

  1. send a test email by pressing 'm' to get started, test me@localhost first
  2. after the mail is sent, press 'G' to get the mail from the pop server, you should have received the email you sent.
  3. repeat with an external email address - all email flowing to your local server should be redirected to me@localhost .