A Mailer for Html Form Content
jMailer is a Java application for e-mailing the content of html forms submitted by users to any number of recipients. It is very simple and easy to configure. It works "out of the box" with Tomcat and JBoss. jMailer has not been tested with other application servers/servlet engines, but should work with others, like Jetty, just as well. What follows is a full explanation of how to configure it.
In the form that is the basis for the e-mail to be sent, we need at least some of the following as hidden elements:
2. <input type="hidden" name="_from value="peter@origin.com" >
3. <input type="hidden" name="_from-name" value="Acme Spam" >
4. <input type="hidden" name="_cacopy" value="bozo@copy.com" > Can be repeated.
5. <input type="hidden" name="_bcc" value="bozo@bcc.com" > Can be repeated.
6. <input type="hidden" name="_topic" value="Topic of the Email" >
7. <input type="hidden" name="_smtp-host" value="localhost" >
8. <input type="hidden" name="_bgcolor" value="#ffffaa" >
9. <input type="hidden" name="_width" value="555" >
10. <input type="hidden" name="_response_page" value="http://www.yoursite.com./thankyou.html" >
If you don't need some of these elements, just leave them out.
In addition to these you may need an smpt username and smtp password. As all these values are visible to anyone who cares to look at the html code, the smtp username and password are not supplied here. The are in a file called web.xml in the war file in the directory WEB-INF. Unzip the war file, find we web.xml file, open it in a text editor (Notepad if you don't know any better, not Word) and make the necessary changes. You will find the right place easily. Either zip the war file back as before and make sure the extension is .war. Depending on your application server it may even deploy as a zip file or you may leave it uncompressed and deploy the whole jmail.war directory. If you do not need an smtp username and password, you can ignore all this.
Note the leading _ This is important. Do not use a leading _ with any other element names. Also, do not repeat any other element names. If you have repeating groups give them names like child1, child2, child3, etc.
_bgcolor is the hexadecimal value of the backgound colour you want your e-mail to be in.
_width is the width of your e-mail in pixels. Most e-mail agents have a window for displaying the message far narrower than your full screen. Your e-mail body (not the email text) will be centered.
_response_page is the fully qualified url of the response page on your site. If everything goes well, this page will be displayed. If problems occur, a page with the problems will be displayed. If you are testing this from your home computer, use your ISP smtp host name. On a commercial server the smtp host is often localhost. You must have an smtp server, like Sendmail or Postfix installed, configured and running on the same machine jMailer runs on for this to work if you cannot use your ISP smtp host, like for deployment on the Internet.
Your input names will be used as descriptions for what is in the relevant text input. Use input names that will be clear when the e-mail reaches its destination. For example, Address, Name, Title, etc. jMailer will capitalize the first letter of any input element name and set the font weight to bold and capitalize the first letter of what the users filled in.
Your opening form tag should look like this:
<form method="post" action="path/to/jmail/mailServlet" [onsubmit="return javascript:verify(this);"]>
The [onsubmit="return javascript:verify(this);"] is optional. If you use it, don't include the angle brackets and create your own javascript function for form verification.
jMailer has been tested in Tomcat and JBoss. It works out of the box in both of them.
The order in which jMailer returns your elements
jMailer mixes them up something real bad. But don't despair, it has been taken care of. Prepend the name of the form element with the number in which sequence you want it returned followed by a hyphen, like so: <input name="01-First Name" ... />
Note the 01 instead of 1. If you have more ten element names number 2 will be returned after number 19, but 02 will be returned before 03. If you have more than 100 elements, start with 001, 002, etc.
The numbers will be chopped off and the element names returned like "First Name" etc.
You will need a JDK 5 for jMailer.
Note that jMailer sends a text email as well as an html email. It uses an Apache Commons mail library which makes this easy. If the email client does not support (or has support turned off) html emails, the text email will be displayed. Otherwise the html email will be displayed.
This is the link where you can download jMailer and its documentation. Right click the link and select "save as"
If you have any problems with jMailer, please contact
.