James: The Java Apache Mail Enterprise Server



Similar documents
Mass ing Techniques

AXIGEN Mail Server. Quick Installation and Configuration Guide. Product version: 6.1 Document version: 1.0

MailEnable Installation Guide

Using WinGate 6 . Concepts, Features, and Configurations.

2- Electronic Mail (SMTP), File Transfer (FTP), & Remote Logging (TELNET)

JBoss Portal 2.4. Quickstart User Guide

Sending an Message from a Process

2- Electronic Mail (SMTP), File Transfer (FTP), & Remote Logging (TELNET)

XMLVend Protocol Message Validation Suite

WaveWare Technologies, Inc. We Deliver Information at the Speed of Light

What really is a Service?

Pine Exchange mini HOWTO

Configuring your client to connect to your Exchange mailbox

Web Design I. Introduction. This first exercise will cover the following concepts: Tutorial Topics

CREATING YOUR ONLINE PRESENCE

Automated Process Center Installation and Configuration Guide for UNIX

Application Monitoring using SNMPc 7.0

Apache James: more than s in the cloud. Ioan Eugen Stan Berlin Buzzwords 2012

IBM. Implementing SMTP and POP3 Scenarios with WebSphere Business Integration Connect. Author: Ronan Dalton

Articles Fighting SPAM in Lotus Domino

Oracle9i Application Server: Options for Running Active Server Pages. An Oracle White Paper July 2001

1z0-102 Q&A. DEMO Version

Talk Internet User Guides Controlgate Administrative User Guide

Outlook XP Only

HOSTED DESKTOP MANUAL

Managing your accounts

Cloud Server powered by Mac OS X. Getting Started Guide. Cloud Server. powered by Mac OS X. AKJZNAzsqknsxxkjnsjx Getting Started Guide Page 1

Djigzo encryption. Djigzo white paper

Outlook 2010 Setup Guide (POP3)

Application Servers - BEA WebLogic. Installing the Application Server

Domains Help Documentation This document was auto-created from web content and is subject to change at any time. Copyright (c) 2016 SmarterTools Inc.

PageScope Router. Version 1.5. Configuration Guide

Quick Start Articles provide fast answers to frequently asked questions. Quick Start Article

Pragmatic Version Control

1. Open Thunderbird. If the Import Wizard window opens, select Don t import anything and click Next and go to step 3.

2sms SMS API Overview

Application Notes for Packaging and Deploying Avaya Communications Process Manager Sample SDK Web Application on a JBoss Application Server Issue 1.

How to make the s you Send with Outlook and Exchange Appear to Originate from Different Addresses

MessageGuard 3.0 User Guide

Emaml.NET ASP.NET Server Control for ArcIMS

Installing GFI FAXmaker

Oracle WebLogic Server

Set up Outlook for your new student e mail with IMAP/POP3 settings

Merak Outlook Connector User Guide

NeoMail Guide. Neotel (Pty) Ltd

Microsoft Outlook. KNOW HOW: Outlook. Using. Guide for using , Contacts, Personal Distribution Lists, Signatures and Archives

MailEnable Web Mail End User Manual V 2.x

Chapter 3 ADDRESS BOOK, CONTACTS, AND DISTRIBUTION LISTS

How to use JavaMail to send

User Guide for the VersaMail Application

Versions Addressed: Microsoft Office Outlook 2010/2013. Document Updated: Copyright 2014 Smarsh, Inc. All right reserved

EventSentry Overview. Part I Introduction 1 Part II Setting up SQL 2008 R2 Express 2. Part III Setting up IIS 9. Part IV Installing EventSentry 11

i2b2 Installation Guide

BUSINESS CLASS POP3 END USER GUIDE TIME WARNER CABLE BUSINESS SERVICES VERSION 1.0, RELEASE 1.2

Microsoft Outlook Reference Guide for Lotus Notes Users

A Java proxy for MS SQL Server Reporting Services

Emacs SMTP Library. An Emacs package for sending mail via SMTP. Simon Josefsson, Alex Schroeder

POP3 Connector for Exchange - Configuration

SERVLETS - SENDING

LDaemon. This document is provided as a step by step procedure for setting up LDaemon and common LDaemon clients.

Table of Contents Chapter 1 INTRODUCTION TO MAILENABLE SOFTWARE... 3 MailEnable Webmail Introduction MailEnable Requirements and Getting Started

Jenkins on Windows with StreamBase

ActiveXperts Network Monitor. White Paper

How To Use Gfi Mailarchiver On A Pc Or Macbook With Gfi From A Windows 7.5 (Windows 7) On A Microsoft Mail Server On A Gfi Server On An Ipod Or Gfi.Org (

The GlobalCerts TM Secur Gateway TM

Networking Applications

Mail Server Scenarios and Configurations

Client Configuration Guide

New Features... 1 Installation... 3 Upgrade Changes... 3 Fixed Limitations... 4 Known Limitations... 5 Informatica Global Customer Support...

Install and configure server

DJIGZO ENCRYPTION. Djigzo white paper

MANUAL. Policy Patrol . Disclaimers. Version 7

Using TLS Encryption with Microsoft Outlook 2007

How to Earn IPv6 Certifications (Windows Version: Fast) Why? Macintosh Instructions Windows Versions Tips for Windows Home Edition Users

Risks with web programming technologies. Steve Branigan Lucent Technologies

Oracle Exam 1z0-102 Oracle Weblogic Server 11g: System Administration I Version: 9.0 [ Total Questions: 111 ]

Setup Guide. network support pc repairs web design graphic design Internet services spam filtering hosting sales programming

esx Client and isx Web Server SCENIX Application Note Overview 2.0 esx Client Client esx Board SMTP Server (EServ)

Ipswitch Client Installation Guide

IRMACS Setup. Your IRMACS is available internally by the IMAP protocol. The server settings used are:

Module One: Getting Started Opening Outlook Setting Up Outlook for the First Time Understanding the Interface...

Summer Internship 2013

Getting started with OWASP WebGoat 4.0 and SOAPUI.

CEFNS Web Hosting a Guide for CS212

INSTALLATION GUIDE VERSION

Guardian Digital Secure Mail Suite Quick Start Guide

Configuring, Customizing, and Troubleshooting Outlook Express

SendMIME Pro Installation & Users Guide

WESTERNACHER OUTLOOK -MANAGER OPERATING MANUAL

Oracle EXAM - 1Z Oracle Weblogic Server 11g: System Administration I. Buy Full Product.

BOTTOM UP THINKING SETUP INSTRUCTIONS. Unique businesses require unique solutions CLIENT GUIDE

FileMaker Server 12. FileMaker Server Help

Sample copy. Introduction To WebLogic Server Property of Web 10.3 Age Solutions Inc.

TouchBase Pro. Users Guide

Transcription:

James: The Java Apache Mail Enterprise Server by Barry Burd and Michael P. Redlich Introduction James is an open source, 100% pure Java e-mail server developed by the Apache Software Foundation. James has all the qualities of an industrial-strength e-mail server, and a few additional qualities that make James unique. James complements the JavaMail 1.3 API in a chain of command that works something like this: A user interacts with an interface that s created using JavaMail. This interface is called the mail user agent (MUA). Think of the MUA as an e-mail client, like Eudora or Outlook Express. The MUA talks to a mail transfer agent (MTA). As an MTA, the James server supports the SMTP and POP3 e- mail protocols, sending e-mail messages to their appointed destinations. James also includes support for IMAP, NNTP, LDAP, and other protocols. This article explains why you should consider using James for your e-mail server needs, shows you how to get started with James, and describes one of James s main features: the Mailet API. Why James? James is a complete, portable, and standalone, enterprise e-mail server solution. Let's take a peek at what makes James stand out in the crowd: Portability James is portable because it s a 100% pure Java. With James you can create custom e-mail applications on Windows, on UNIX, on cell phones, on weed whackers, on anything. Complete and Standalone James is complete because it doesn't require additional support from other servers or applications. This makes James standalone because it can handle both mail transport and storage as a single server application. Other e-mail servers may rely on required third party applications for getting the functionality you need. James contains functionality from other Apache projects, but everything is packaged as one application. Abstraction James follows a loosely coupled plug-in design. For some products, phrases like loosely coupled and separation of this from that are just hype. But James separates things intelligently. With James, each protocol plugs into the messaging framework. So, for example, James supports SMTP. But you can unplug SMTP, plug Jabber in place of SMTP, and have a nice, portable instant messaging application.

In fact, James uses abstraction from top to bottom. Resources such as JDBC (for spooling or user accounts stored in databases) are abstracted just as protocols are. James takes advantage of the defined interfaces for each of these resources to maintain modularity and good design. Multi-Threaded James is fully multi-threaded for performance and scalability. James is based on Apache Avalon, an open source server framework that provides a common method for developing and implementing server components. The Avalon Framework (AF) supports Inversion of Control (IoC). Best of all, you don't need to write code to use Avalon Framework components. All you do is use a container such as Avalon Phoenix or Excalibur Fortress. The container does the work for you. (Oops! Apache has closed its Avalon project! But don t worry. All is well with James. The James project committee assures everyone that James will press on without Avalon. Whew!) Mailet Support James s Mailet API allows you to customize e-mail processing for your enterprise s needs. James has a number of predefined mailet classes. For example, the AddFooter class appends specified text to the bottom of message body. The James documentation gives you the complete list of pre-defined mailets. But, of course, you can write your own mailets. All you have to do is to extend the GenericMailet and GenericMatcher classes. For more information, see the Mailets and Matchers section later in this article. Reliability and Scalability James was first released in 1999. Since then, a number of organizations have implemented James in production environments. The James Wiki page lists many of these organizations. One organization designed and implemented a scalability test on James with a result of 2600 e-mail messages per minute. Now that's impressive! Price Best of all, James is free, and that is certainly good news for organizations and companies with small IT budgets. James isn t an expensive e-mail server such as Microsoft Exchange or Lotus Domino, but James rivals other e-mail server solutions in robustness and scalability. Getting Started Now that we ve piqued your interest, let's get started working with James. Download and Installation The most recent stable version of James (v2.2.0) is available from the James web site. As with most open source projects, you have a choice of downloading the full source code (and compiling it yourself), or downloading the binary code in either ZIP and TAR formats. If you re serious about e-mail, you may want a few additional downloads namely, the JavaMail 1.3 API, the JavaBeans Application Framework (JAF) 1.0.5, and Apache Ant 1.6.5.

Before starting James for the first time, you should set your JAVA_HOME environment variable to the directory where you installed the JDK, e.g., set JAVA_HOME=C:\jdk1.5.0_04 Starting the Server You can start James by executing one of the command line utilities in James s bin subdirectory: run.bat (Windows) wrapper.exe -c..\conf\wrapper.conf (Windows) run.sh (UNIX) The wrapper utility includes options for installing/removing the server as an NT service. When you start James for the very first time, it unpacks the contents of the james.sar file and stores the contents in the james-2.2.0/apps directory. Server Administration You can administer the James server through its Remote Administration Tool. You access the tool by telnetting to port 4555: telnet localhost 4555 When it starts, the Remote Administration Tool prompts you for authentication. The default userid is root and the default password is root. After logging on you can perform common administrative server tasks such as adding/modifying/deleting user accounts. You can obtain the list of available commands by typing the command, help. Adding Users You can easily add users with the Remote Administration Tool s adduser command: adduser alan 5ibgm8pn adduser barry f3qaid37 adduser carol z9oxzfva adduser diane bwwvh002 The first parameter is the userid and the second parameter is the password. Stopping the Server You can stop the James server by typing CTRL-C in the original run.bat or run.sh window. But when you type CTRL-C, you see a nasty-looking JVM exiting abnormally message. So it s better to stop the server with the Remote Administration Tool s shutdown command.

Mailets and Matchers One of the neat things about James is the use of mailets and matchers. A mailet is a Java class that does something with a mail message, like adding a footer, forwarding the message, notifying the postmaster about the receipt of the message, or whatever else a mail server may want to do. A matcher is a Java class that says Yes, apply this mailet s instructions to that message for these recipients, and No, don t apply this mailet s instructions to that message for those other recipients. How Matchers and Mailets Work Together Let s make this Matcher/Mailet business a bit more precise: Each mailet contains a method named service. A typical service method looks like this: public void service(mail mail) throws MessagingException { MimeMessage mimemessage = mail.getmessage(); // Do things with the message mimemessage.savechanges(); The MimeMessage class belongs to the javax.mail.internet package, and the Mail class is part of the org.apache.mailet package. Each matcher contains a method named match. A typical match method looks like this: public Collection match(mail mail) { if ( /* something or other is true */ ) { return mail.getrecipients(); else { return null; Despite our simplified explanation in the earlier bullets, an invocation of the match method doesn t return yes or no. Instead, the match method returns a list of recipients for which a mailet should be processed. Take, for instance, an AddFooter mailet that pastes the words FOR YOUR EYES ONLY at the bottom a message body. A particular message may have recipients Alan, Barry, Carol, and Diane. So the skeletal match method above may return a collection containing Alan, Barry, Carol, and Diane. This collection tells James to add FOR YOUR EYES ONLY to the copies sent to all four recipients. On the other hand, the match method above may return null. In that case, James adds FOR YOUR EYES ONLY to none of the message s recipients. Of course, if you rewrite the match method, you may return a collection containing only Barry and Carol, or some other bunch from the message s original list of recipients.

How do you associate a matcher with a mailet? The James config.xml file contains mailet tags. Here s a nice mailet tag: <mailet match="sizegreaterthan=1k" class="addfooter"> <text>warning: Attachments may contain viruses!</text> </mailet> The tag uses a matcher named SizeGreaterThan and a mailet named AddFooter. Both of these classes (the SizeGreaterThan matcher and the AddFooter mailet) are provided as part of the James distribution. When you write a mailet tag, you normally supply parameters to both the mailet and the matcher. A parameter to a mailet is an XML element. For example, in the tag above, the text element tells the AddFooter mailet what text the footer must contain. A parameter to a matcher is buried inside the mailet tag s match attribute. In the tag above, the match attribute specifies the name of the matcher class (SizeGreaterThan) and the 1k (1 kilobyte) parameter value. If a message has size greater than 1 kilobyte, then James adds a Warning: Attachments may contain viruses! footer at the bottom of the message. Matcher and Mailet Classes We wanted to give James a test run, but we needed an excuse to write a matcher and a mailet. So we dreamt up a fairly frivolous scenario. Here s how it goes: We re strong advocates of Java technology, and we re dismayed by any mention of.net. So when we receive e-mail messages containing the characters.net we want to blot out those characters and replace them with some alternate text. What we really need is a ReplacePlainText mailet. The mailet looks for all occurrences of a certain string, and replaces such occurrences with other (less upsetting) text. There's only one exception. We have a mutual friend named Manny, who works with both Java and.net. (Manny's ongoing effort is to port portions of the Java API to the.net platform.) Manny has many e-mail addresses, each of the form Manny@some-domain-or-other. Our goal is to allow mail from Manny@anything-at-all (and no other mail) to display the word.net. So our SenderIsNot matcher class takes an incoming e-mail message. If the sender isn t Manny@some-domain-or-other, then the matcher returns all the message s recipients. That is, the matcher tells James to apply the ReplacePlainText mailet to every recipient s copy of the message. If the sender is Manny@some-domain-or-other, then the matcher returns null. This tells James to apply the ReplacePlainText mailet to none of the recipients copies. The matcher and mailet classes are in Listings 1 and 2 respectively. The XML tag to make James use the matcher with the mailet is in Listing 3. /******************************************************************* * Adapted by Barry Burd from the SubjectStartsWith method * * which is part of James (http://james.apache.org) * * which is Copyright (c) 2000-2004 The Apache Software Foundation.* *******************************************************************/

package org.apache.james.transport.matchers; import org.apache.mailet.genericmatcher; import org.apache.mailet.mail; import java.util.collection; public class SenderIsNot extends GenericMatcher { String sendername = null; public void init() throws javax.mail.messagingexception { sendername = getcondition(); public Collection match(mail mail) { if (mail.getsender().getuser().equals(sendername)) { return null; else { return mail.getrecipients(); Listing 1: A simple matcher. package org.apache.james.transport.mailets; import java.io.ioexception; import javax.mail.messagingexception; import javax.mail.internet.mimemessage; import org.apache.mailet.genericmailet; import org.apache.mailet.mail; public class ReplacePlainText extends GenericMailet { String oldphrase; String newphrase; public void init() throws MessagingException { oldphrase = getinitparameter("oldphrase"); newphrase = getinitparameter("newphrase"); public void service(mail mail) throws MessagingException { MimeMessage mimemessage = mail.getmessage(); String oldbody = null, newbody = null; try { oldbody = mimemessage.getcontent().tostring(); catch (IOException e) { e.printstacktrace(); catch (MessagingException e) { e.printstacktrace(); newbody = oldbody.replaceall(oldphrase, newphrase); mimemessage.settext(newbody); mimemessage.savechanges(); Listing 2: A simple mailet.

<mailet match="senderisnot=manny" class="replaceplaintext"> <oldphrase>\.net</oldphrase> <newphrase>!^#%</newphrase> </mailet> Listing 3. A mailet tag in the config.xml file. Both the matcher and the mailet contain init methods. In each init method, the Java program reads parameters from the mailet tag. The matcher s init method calls getcondition, which reads the word Manny from Listing 3. The mailet s init method calls getinitparameter, which reads the strings \.NET and!^#% from Listing 3. Inside the mailet tag, the match attribute s value takes the form match="matcher-class-name=parameters" The getcondition method reads the parameters string, which in Listing 3 is the word Manny. When a mail message arrives, James calls the match method in Listing 1. If the message s sender is Manny, the match method says, Don t apply the mailet to any of the message s recipients. If the message s sender isn t Manny, the match method says Apply the mailet to all of the message s recipients. By the way, some matchers have what you d normally think of as several parameters. For instance, I may want to allow the word.net to appear in messages from three people named Manny, Moe, and Jack. In that case I d stuff all three names into one delimited string. match="senderisnot=manny,moe,jack" Then I d write business logic inside the match method to parse the string and use the three names appropriately. So assume that Fred@dotnetlover.com sends me an e-mail message containing the word.net. Then the match method in Listing 1 tells James to apply the mailet s logic to this message. In response, James calls the service method of Listing 2, and replaces all occurrences of.net with the string!^#%. (In Listing 3, the backslash before.net ensures that the replaceall method doesn t mistake the dot for a regular expression s any character symbol.) Conclusion James is an efficient, robust e-mail server with an architecture that s ripe for future expansion. Upcoming releases of James may support instant messaging, new e-mail protocols, and other exciting features. James s plug-in design goes hand-in-hand with Java portability, making James a good choice for an enterprise-level e-mail server. About the Authors Barry Burd is a professor in the Department of Mathematics and Computer Science at Drew University in Madison, New Jersey. When he's not lecturing at Drew University, Dr. Burd leads training courses for professional programmers in business and industry. He has lectured at conferences in America, Europe, Australia and Asia. He is the author of several articles and books, including Java 2 For Dummies and Eclipse For Dummies, both published by Wiley.

Michael P. Redlich is a Senior Research Technician (formerly a Systems Analyst) at ExxonMobil Research & Engineering, Co. with extensive experience in developing custom web and scientific laboratory applications. Mike also has experience as a Technical Support Engineer for Ai-Logix, Inc. where he developed computer telephony applications. He has a Bachelor of Science in Computer Science from Rutgers University. Mike's computing experience includes computer security, relational database design and development, object-oriented design and analysis, C/C++, Java, Visual Basic, FORTRAN, Pascal, MATLAB, HTML, XML, ASP, VBScript, and JavaScript in both the PC and UNIX environments.