Download the app | Test the app | View the documentation
This is a servlet which handles all the features of a POP3 mail account. The initial code was from Professional Java Server Programming published by Wrox. The idea behind this servlet is to serve as an example of how Javamail can operate in a Web environment. I did this because Javamail is fairly simple but there aren't that many applications which make it clear to a beginner or intermediate programmer how to use some of the features. If this was a commercial application, it would probably be split into several classes and would obviously have much more robust error handling.
I added the following features to the original wrox servlet
- The servlet makes use of an external html template
- The servlet can allow the user to send an attachment
- The servlet will print out messages with attachments
- The user can download any attachments in the same way yahoo or hotmail users can
To set up this on your own server, you will need to:
- Put the templates (WebMail.html) into a directory on your server
- Add the correct absolute file paths and directory paths to the templates at the top of the servlet
- Add the cos.jar to your WEB-INF/library. This is the O'Reilly multipart application which allows you to upload attachements that you want to send to a temporary directory. you can find out more information about this application at http://www.servlet.com
- Add the activation.jar and the mail.jar to your WEB-INF/library
- Compile the servlet and put it in your WEB-INF/classes directory
That's it! You're ready to go