|
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
From the Blogosphere Mailets and Matchers
Using Apache James and JavaMail to implement variable envelope return paths
By: Aaron Johnson
Sep. 27, 2006 04:00 PM
Apache James is a full-featured SMTP, POP3, and NNTP server built using 100% Java and more importantly it's been designed from the ground up to be a mail application platform
...each recipient of the message sees a different envelope sender address. When a message to the djb-sos@silverton.berkeley.edu mailing list is sent to God@heaven.af.mil, for example, it has the following envelope sender: djb-sos-owner-God=heaven.af.mil@silverton.berkeley.edu If the message bounces, the bounce message will be sent back to djb-sos-owner-God=heaven.af.mil@silverton.berkeley.edu. If God is forwarding His mail, the bounced message will still go to djb-sos-owner-God=heaven.af.mil@silverton.berkeley.edu. No matter how uninformative the bounced message is, it will display God's subscription address in its envelope. But you probably noticed that this article isn't only about VERP: Apache James is a full-featured SMTP, POP3, and NNTP server built using 100% Java and more importantly it's been designed from the ground up to be a mail application platform. The James mail application platform makes it a perfect candidate for handling bounced messages using VERP. Similarly, the JavaMail API is a framework for building mail and messaging applications using SMTP and POP3. JavaMail makes it easy to customize the envelope sender address, which means Java developers can use JavaMail on the client and James on the server to build e-mail applications that enables VERP. This article will describe an example VERP implementation, show how JavaMail can be used to modify the envelope sender address, and then illustrate how James can be used to recognize and process bounced e-mail messages. It's not intended to be an in-depth look at either the Apache James mail server or the JavaMail API. If you're interested in learning more about Apache James, a product review is available on the Sys-Con.com Web site (http://java.sys-con.com/read/38667.htm) and an extensive introduction to Apache James on the IBM developerWorks sit (www-128.ibm.com/developerworks/library/j-james1.html). The JavaMail API can also be reviewed on the Sys-Con.com site: http://java.sys-con.com/read/36545.htm.
VERP and JavaMail
String sendere-mail = "deals@javazon.com"; The code above will produce an e-mail message with headers that look like this:
Date: Wed, 26 Apr 2006 21:00:21 -0000 Because they want to be good e-mail citizens, the developers at Javazon use the POP3 functionality in JavaMail to retrieve the e-mails that bounce back to the address specified as 'sendere-mail' in the example above. Unfortunately, many of the bounced e-mails come from daemon accounts (instead of the recipient e-mail address), which makes it difficult to figure out what e-mail address the original message was sent to. As mentioned at the beginning of this article, the only way to address the bounces that come from daemon accounts is to use VERP, which is a two-part process. The first is relatively simple. An e-mail message, according to the SMTP RFC-821 Section 2, is composed of two parts: an envelope that contains the SMTP source and destination addresses and the message, which consists of the headers and message body. To create a VERP-capable e-mail message, you only need to modify the envelope, which is easily done using the instance of java.util.Properties associated with the javax.mail.Session. Modifying the first example, the developers would end up with this:
String sendere-mail = "deals@javazon.com"; When executed, this code would create an e-mail message with headers that look like this:
Return-Path: <deals-ajohnson=cephas.net@javazon.com> Notice the different "Return Path:" header from the first e-mail? If the e-mail message bounces back to Javazon, it will go to the e-mail address associated with the 'Return Path' header: "deals-ajohnson=cephas.net@javazon.com" rather than "deals@javazon.com." This is where Apache James comes into the picture.
VERP and James
<filter> The servlet container limits how you match requests to a filter: you're limited to pattern matching on the URL. Instead of a <filter> and <filter-mapping>, James gives you a <mailet> made up of two parts: Matchers and Mailets. They're described on the James wiki: "Matchers are configurable filters which filter mail from a processor pipeline into Mailets based upon fixed or dynamic criteria. "Mailets are classes that define an action to be performed. This can cover actions as diverse as local delivery, client-side mail filtering, switching mail to a different processor pipeline, aliasing, archiving, list serving, or gateways into external messaging systems." Reader Feedback: Page 1 of 1
Latest Cloud Developer Stories
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week
Breaking Cloud Computing News
|
|||||||||||||||||||||||||||||||||||||||||||||||||