Note: This was tested on trunk and should be the same steps for Geronimo v1.2 and v2.0 with minor changes specifically references to JavaMail module ID.

1. Download Apache JAMES from:

2. Unzip file and run JAMES by executing: \james-2.3.0\bin\run.bat. You should see something like this:

Phoenix 4.2

James Mail Server 2.3.0
Remote Manager Service started plain:4555
POP3 Service started plain:110
SMTP Service started plain:25
NNTP Service started plain:119
FetchMail Disabled

3. Make sure JavaMail module is started:

  • For trunk and v2.0-M1: org.apache.geronimo.configs/javamail/2.0-SNAPSHOT/car (by default this is started)
  • For v1.2-beta: org.apache.geronimo.configs/javamail/1.2-beta/car (by default this is not started)
  • To start the module you can:

a. Use the Web Console: Applications > System Modules > Click 'Start' link beside the JavaMail module ID

b. Use command line deployer:

cd <geronimo_home>\bin
java -jar deployer.jar --user system --password manager start org.apache.geronimo.configs/javamail/2.0-SNAPSHOT/car

c. Stop the server. Modify <geronimo_home>\var\config\config.xml and set JavaMail module load attribute to 'true':

<module load="true" name="org.apache.geronimo.configs/javamail/2.0-SNAPSHOT/car">
    <gbean name="SMTPTransport">
        <attribute name="host">localhost</attribute>
        <attribute name="port">25</attribute>

Note: You can configure the SMTP transport's host and port by overriding the values of the SMTPTransport GBean attrbitues. For our test we will use the default. This will allow us to connect to JAMES running in localhost and using port 25 (the default SMTP port).

3. Create a simple webapp (sendmail.war - attached in this issue) containing the following files:

  + index.jsp
    + web.xml
    + geronimo-web.xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns=""
    <display-name>Send Mail Webapp</display-name>
        <!-- Used in index.jsp -->


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="">
        <!-- Used is web.xml -->
        <!-- Default Geronimo mail session -->


<%@page import="java.util.Date,
                javax.naming.InitialContext" %>

    String resultMsg = "";
    String action = request.getParameter("action");
    if ("Send".equals(action)) {
        String from = request.getParameter("from");
        String to = request.getParameter("to");
        String subject = request.getParameter("subject");
        String content = request.getParameter("message");

        // Get mail session and transport
        InitialContext context = new InitialContext();
        // Mail session from web.xml's resource reference
        Session mailSession = (Session) context.lookup("java:comp/env/mail/testMailSession");
        Transport transport = mailSession.getTransport("smtp");
        // Setup message
        MimeMessage message = new MimeMessage(mailSession);
        // From address
        message.setFrom(new InternetAddress(from));
        // To address
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        // Subject
        // Content
        // Send message
        // Build result message
        resultMsg = "<b>Result:</b>";
        resultMsg += "<br>Message sent: " + new Date();
        resultMsg += "<br>To: " + to;
        resultMsg += "<br>From: " + from;

        <title>Send Mail</title>
                    <td align="center" colspan="2"><b>Send Mail</b></td>
                    <td align="right">From:</td>
                    <td><input type="text" name="from"></td>
                    <td align="right">To:</td>
                    <td><input type="text" name="to"></td>
                    <td align="right">Subject:</td>
                    <td><input type="text" name="subject"></td>
                    <td align="right">Message:</td>
                    <td><textarea rows="5" cols="20" name="message"></textarea></td>
                    <td align="right" colspan="2">
                        <input type="submit" name="action" value="Send">&nbsp;<input type="reset"></td>
        <%= resultMsg %>

4. Deploy sendmail.war:

a. Using Web Console: Applications > Deploy New > Set 'Archive:' to sendmail.war and click 'Install'

b. Using command line deployer:

cd <geronimo_home>\bin
java -jar deployer.jar --user system --password manager deploy sendmail.war

5. Test send mail webapp by going to: http://localhost:8080/sendmail

Fill up the form (From, To, Subject, Message fields) and click 'Send' button. You should get a similar message if the mail was sent successfully:

Message sent: Fri Dec 15 01:10:05 PST 2006
  • No labels