Solprovider Lenya Kongregate Registration for Free Flash Games and Chat with solprovider



1. Download two files from Sun: = Java Activation Framework = Java Mail

2. Unzip them

3. Put these two jars in build/lenya/webapp/WEB-INF/lib

4. Restart Lenya so the new Java libraries are noticed.

TestMail Usecase

1. Flow Javascript
FILE: {pub}/flow/testmail/code.js
function mail() {
var properties = new;
properties.setProperty("protocol", "smtp");
properties.setProperty("type", "transport");
properties.setProperty("class", "com.sun.mail.smtp.SMTPTransport");
properties.setProperty("", "")
var session = new Packages.javax.mail.Session.getInstance(properties);
var message = new;
var address = new Packages.javax.mail.internet.InternetAddress();
message.setSubject("Test JavaMail");
message.setText("This is a test of JavaMail.", "UTF-8");
message.addRecipient(Packages.javax.mail.Message.RecipientType.TO, address);
var urlname = new Packages.javax.mail.URLName("smtp://")
var transport = new, urlname);

Notice setText() has a second parameter "UTF-8". That is pointless in this example, but very important if you are creating the text string from input from a Flow form. Without it, all double-byte input would be converted to question marks ('?':hex 73) and lost forever. With the setting, you can use something like:
"NAME: " + + "\n" + model.comment

2. Change the mail server (twice) and the To and From addresses. HINT: Search for "".

3. Usecase XMAP
FILE: {pub}/usecase-testmail.xmap
<?xml version="1.0" encoding="UTF-8"?>
<map:sitemap xmlns:map="">
<map:flow language="javascript">
<map:script src="flow/testmail/code.js"/>
<map:match pattern="**.html">
<map:call function="mail"/>
<map:match pattern="testmail-success">
<map:redirect-to uri="/"/>

4. Test. Just add "?lenya.usecase=testmail" to any URL and an email will be sent:

The browser should return to the homepage. Check the Inbox of the To address to see the email.

<< XMAPs and XMLContact Us >>

Contact Solprovider
Paul Ercolino