No SSL With ColdFusion's CFPOP?

I was very surprised to find out that ColdFusion's CFPOP tag does not support POP3 SSL. ColdFusion is over 10 years old now...you've got to add that in, Adobe!

Anyway, I did some digging around, and thanks to a comment on another blog by Darin Tyler, I found an easy fix. You can use some simple Java commands to "force" cfpop to use SSL. In my testing, I used Gmail, and the code is below:

<cfset javaSystem = createObject("java", "java.lang.System") />
<cfset javaSystemProps = javaSystem.getProperties() />
<cfset javaSystemProps.setProperty("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory") />

<cfpop
   server="pop.gmail.com"
   action="getAll"
   name="popMessages"
   port="995"
   username="myemailaddress@gmail.com"
   password="i'mnotgoingtotellyou">

Comments
Jake, I definitely share the frustration that CFPOP doesn't let you specify the use of SSL. They implemented SSL (as well as TLS) in CFMAIL, so why not in CFPOP?

The Java call is the way to go, and I wanted to share one additional technique I've used with it: you'll want to turn SSL off if the user turns it off to access another POP account, or if the same application serves multiple users who don't all use SSL. So after you turn SSL on with the line:

<cfset javaSystemProps.setProperty("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory") />

You can turn it off with:

<cfset javaSystemProps.setProperty("mail.pop3.socketFactory.class", "javax.net.SocketFactory") />
# Posted By Tom Mollerus | 3/28/08 10:29 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9. Contact Blog Owner