Ok then I will... ;)

Never one to turn down a challenge, but having no clue what I was
doing my first thought was to try brute force...and it worked.

So here are the steps for anyone interested.
Download Javamail 1.3 from Sun's site.
Shut down Cold Fusion.
Make backup of CFusionMX\runtime\lib\jrun.jar.
Make backup of CFusionMX\runtime\lib\jrun.jar.
Read the above two lines again.
Using Jar archive manager of choice (I used WinRar), and open both
jrun.jar and the mail.jar file from the Javamail 1.3 download.
In the mail.jar file, navigate the the javax\mail directory and copy
it to the clipboard.
Int the jrun.jar file, navigate to the javax directory and paste
files. WinRar will do it's thing and write out a file called
something like "zias.j40". That's the new and improved jrun.jar.
Rename it to jrun.jar, and start up ColdFusion again.

Congratulations, you now have Javamail 1.3, probably voided all
warranties, and gained access to the nifty validate() method!

Some example code:

<cfset objJavamail = createObject("java", "javax.mail.internet.InternetAddress")>
<cfdump var="#objJavamail#">

<cfset emailAddress = "inv@[EMAIL PROTECTED]">
<cfset objJavamail.init(emailAddress, true)>

<cftry>
        <cfset objJavamail.validate()>
        <cfcatch type="javax.mail.internet.AddressException">
                <cfoutput>#cfcatch.message#</cfoutput>
        </cfcatch>
</cftry>
<cfoutput>
#objJavamail.getAddress()#
</cfoutput>

This doesn't catch everything a tweaked regex catches, but it does
catch a lot, and it gives a very specific english error message. It's
also very fast. There are a lot of other handy methods in the InternetAddress
class too. You can make it try and correct an invalid email address
even. Seems to do a pretty good job at it.
Link to docs:
http://java.sun.com/products/javamail/1.3/docs/javadocs/index.html

I'm starting to think this MX stuff is pretty cool. There is a lot of
untapped power built into Java that I can't wait to see exposed in CF.

-- 
jon
mailto:[EMAIL PROTECTED]

Saturday, October 5, 2002, 11:48:09 PM, you wrote:

KS> It looks like you can just upgrade the JavaMail portion to 1.3...  Try it
KS> and tell us what happened :)

>> -----Original Message-----
>> From: Jon Hall [mailto:[EMAIL PROTECTED]]
>> Sent: Saturday, October 05, 2002 7:29 PM
>> To: CF-Talk
>> Subject: Re: MX and Javamail
>>
>>
>> To answer my own question... A quick scan of the J2EE 1.3 specs shows
>> that Javamail 1.2 is required of a web implementation of J2EE.
>> So, MX uses Javamail 1.2.
>>
>> The J2EE 1.4 Proposed Final Draft does require 1.3 though, so
>> hopefully in the next version of MX, I'll be able to get rid of my
>> hokey regex and use Javamail to validate email addresses.
>>
>> --
>> jon
>> mailto:[EMAIL PROTECTED]
>>
>> Friday, October 4, 2002, 7:14:45 PM, you wrote:
>>
>> ksc> Ahh, I see.  Not sure if MX uses JavaMail, or just uses
>> JRun's implementation of the j2ee spec.
>>
>> ksc> ----- Original Message -----
>> ksc> From: jon hall <[EMAIL PROTECTED]>
>> ksc> Date: Friday, October 4, 2002 5:11 pm
>> ksc> Subject: Re: MX and Javamail
>>
>> >>
>> http://java.sun.com/products/javamail/1.3/docs/javadocs/javax/mail
KS> /internet/InternetAddress.html#validate()
>>>


KS> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

Reply via email to