CFPOP + SSL

595 views
Skip to first unread message

Sean Daniels

unread,
Nov 12, 2009, 10:55:14 AM11/12/09
to Railo
I need to access a gmail account using CFPOP. As Gmail requires an SSL
connection on port 995, this is not currently working using the normal
CFPOP syntax. I found this workaround for CFPOP in ColdFusion (http://
www.anujgakhar.com/2008/05/18/cfpop-and-gmail/), wondering if anyone
has implemented something similar in Railo (3.1.1.000). I'm gonna see
if I can figure it out and will report back if I do, but if someone
else has already done this please let me know!

Thanks,
Sean

Ryan Letulle

unread,
Nov 12, 2009, 11:18:06 AM11/12/09
to ra...@googlegroups.com
Are you just looking for sample code?
--
Ryan LeTulle

JediHomer

unread,
Nov 12, 2009, 11:19:16 AM11/12/09
to ra...@googlegroups.com
You could have a look at

http://popcfc.riaforge.org/


2009/11/12 Sean Daniels <daniel...@gmail.com>:

Ryan Letulle

unread,
Nov 12, 2009, 11:20:39 AM11/12/09
to ra...@googlegroups.com
<!--- Gmail has to be checked using ssl --->
<cfset javaSystem = createObject("java", "java.lang.System") />
<cfset javaSystemProps = javaSystem.getProperties() />
<cfset javaSystemProps.setProperty("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory") />
 
<!--- Check incoming mail and return as a query --->
<cfpop action="getall"  server="pop.gmail.com" username="your...@changethis.com" password="yourpassword" name="getmail" port="995">


Works for me.  I am sure there are other ways.

--
Ryan LeTulle


On Thu, Nov 12, 2009 at 9:55 AM, Sean Daniels <daniel...@gmail.com> wrote:

Sean Daniels

unread,
Nov 12, 2009, 12:13:56 PM11/12/09
to Railo
Ryan, do you have this code working in Railo? I have tried this and it
still doesn't work, I just get a connection timeout.

On Nov 12, 11:20 am, Ryan Letulle <bayous...@gmail.com> wrote:
> <!--- Gmail has to be checked using ssl --->
> <cfset javaSystem = createObject("java", "java.lang.System") />
> <cfset javaSystemProps = javaSystem.getProperties() />
> <cfset javaSystemProps.setProperty("mail.pop3.socketFactory.class",
> "javax.net.ssl.SSLSocketFactory") />
>
> <!--- Check incoming mail and return as a query --->
> <cfpop action="getall"  server="pop.gmail.com" username="
> yourem...@changethis.com" password="yourpassword" name="getmail" port="995">
>
> Works for me.  I am sure there are other ways.
>
> --
> Ryan LeTulle
>

Todd Rafferty

unread,
Nov 12, 2009, 12:18:08 PM11/12/09
to ra...@googlegroups.com
Do you have a firewall blocking you by any chance?

~Todd Rafferty ** Volunteer Railo Open Source Community Manager ** http://getrailo.org/

Sean Daniels

unread,
Nov 12, 2009, 12:27:07 PM11/12/09
to Railo
No firewall. I'm running Railo locally and I have tested my connection
by configuring a normal mail client (Mail.app) to check the Gmail
account and it works fine.

On Nov 12, 12:18 pm, Todd Rafferty <t...@getrailo.org> wrote:
> Do you have a firewall blocking you by any chance?
>
> ~Todd Rafferty ** Volunteer Railo Open Source Community Manager **http://getrailo.org/

Ryan Letulle

unread,
Nov 12, 2009, 12:41:02 PM11/12/09
to ra...@googlegroups.com
Sean,

Sorry I did not test lately.  I am timing out as well.

I heard from a colleague last night that he was troubleshooting a Google POP issue.  Not sure if it's related.  But if you can connect through a client I would think not.

I don't know if this helps anyone else.  I guess it's possible it would take more than 50 seconds.

request (path: /path removed/pop/checkmail.cfm:11) is run into a timeout (50 seconds) and has been stopped. no open locks

Java Stacktrace
request (path: /path removed/pop/checkmail.cfm:11) is run into a timeout (50 seconds) and has been stopped. no open locks
at railo.runtime.exp.PageRuntimeException.<init>(PageRuntimeException.java:37):37
at railo.runtime.CFMLFactoryImpl.checkTimeout(CFMLFactoryImpl.java:195):195
at railo.runtime.engine.Controler.run(Controler.java:109):109
at railo.runtime.engine.Controler.run(Controler.java:91):91


--
Ryan LeTulle

Sean Daniels

unread,
Nov 12, 2009, 12:50:53 PM11/12/09
to Railo
It seems to me like maybe Railo's cfpop is internally resetting the
mail.pop3.socketFactory.class property or perhaps it does not even use
this property. If I take a stack trace while the request is running I
get this:

java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:???)
[Native Method]
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
java.net.Socket.connect(Socket.java:525)
com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:230)
com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
com.sun.mail.pop3.Protocol.(Protocol.java:81)
com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:201)
com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:144)
javax.mail.Service.connect(Service.java:275)
javax.mail.Service.connect(Service.java:156)
railo.runtime.net.mail.MailClient.connect(MailClient.java:159)
railo.runtime.tag._Mail.doStartTag(_Mail.java:189)
<snip>

I would expect to see some SSL related stuff in there.

Sean Daniels

unread,
Nov 13, 2009, 10:55:46 AM11/13/09
to Railo
PopCFC looked promising but is basically just a wrapper for the other
ColdFusion workaround (<cfset javaSystemProps.setProperty
("mail.pop3.socketFactory.class",
"javax.net.ssl.SSLSocketFactory") />).

This workaround does not appear to work in Railo. I looked at the
MailClient.java source in Railo and if I understand correctly it looks
to me like Railo creates it's own local set of properties to use when
creating the POP3 connection which would explain why setting these
system properties doesn't have any effect.

Thanks to all who have made suggestions so far... still holding out
for a solution...

Michael Offner-Streit

unread,
Nov 13, 2009, 12:08:42 PM11/13/09
to ra...@googlegroups.com
can you make a feature request for this in jira, we are working on cfpop in the next time, then we can look into it
and make a solution or workaround
https://jira.jboss.org/jira/browse/RAILO

/micha

Sean Daniels schrieb:

Sean Daniels

unread,
Nov 13, 2009, 12:18:16 PM11/13/09
to Railo
Thanks micha, you may have seen I had already done this this
morning! :)

https://jira.jboss.org/jira/browse/RAILO-506

Let me know if I can help in any way. I'm trying to get the source to
compile on my machine, was gonna tinker with it myself, but admittedly
I'm out of my league a bit there.


On Nov 13, 12:08 pm, Michael Offner-Streit <michael.off...@railo.ch>
wrote:
> can you make a feature request for this in jira, we are working on cfpop
> in the next time, then we can look into it
> and make a solution or workaroundhttps://jira.jboss.org/jira/browse/RAILO
>
> /micha
>
> Sean Daniels schrieb:
>
>
>
>
>
> > PopCFC looked promising but is basically just a wrapper for the other
> > ColdFusion workaround (<cfset javaSystemProps.setProperty
> > ("mail.pop3.socketFactory.class",
> > "javax.net.ssl.SSLSocketFactory") />).
>
> > This workaround does not appear to work in Railo. I looked at the
> > MailClient.java source in Railo and if I understand correctly it looks
> > to me like Railo creates it's own local set of properties to use when
> > creating the POP3 connection which would explain why setting these
> > system properties doesn't have any effect.
>
> > Thanks to all who have made suggestions so far... still holding out
> > for a solution...
>
> > On Nov 12, 11:19 am, JediHomer <jediho...@gmail.com> wrote:
>
> >> You could have a look at
>
> >>http://popcfc.riaforge.org/
>
> --
> Michael Offner-Streit
> CTO
> Railo Technologies GmbH
> michael.off...@railo.chwww.getrailo.com

denstar

unread,
Nov 13, 2009, 1:58:31 PM11/13/09
to ra...@googlegroups.com
I never heard back from the guy who wanted something like this before,
but you could theoretically merge the imap.cfc with the pop3 settings
and use it, as imap.cfc does everything using javamail.

If you're burning for a work-around I can try to dig up what I posted
for the other guy (on cf-talk, I think).

I'll go look for it in a bit.

--
What a man is ashamed of is always at bottom himself; and he is
ashamed of himself at bottom always for being afraid.
Robin G. Collingwood

Sean Daniels

unread,
Nov 13, 2009, 2:04:05 PM11/13/09
to Railo
I will definitely check that out. IMAP is an option for me so maybe I
can just use Imap.cfc out of the box.

Thanks for the suggestion denstar.

denstar

unread,
Nov 13, 2009, 4:59:42 PM11/13/09
to ra...@googlegroups.com
No problemo!

I dug up something that looks promising, tho it's so old Rick might
have made improvements to the core since it was first manhandled to do
pop3s:

http://cfml.pastebin.com/f6f5c8051

Seems to work for imaps or pop3s, from these tests:

var protocol="pop3";
var username="vallia...@gmail.com";
var password="ohNoIforgotToSanitize!";
var mailserver="pop.gmail.com";
var port="995";
var timeout="3";
var connected =
javamail.init(protocol,username,password,mailserver,port,timeout);
assertTrue(connected);
debug(javamail.getFolderInfo("INBOX"));
debug(javamail.getMessageCount("INBOX"));
messageList = javamail.listMessages("INBOX","",1,10);
request.debug(messageList);

and:

var protocol="imaps";
var username="vallia...@gmail.com";
var password="cheeseVsBacon==bedlam!";
var mailserver="imap.gmail.com";
var port="993";
var timeout="3";
var connected = javamail.init(protocol,username,password,mailserver);
assertTrue(connected);
debug(javamail.getFolderInfo("INBOX"));
debug(javamail.getMessageCount("INBOX"));
messageList = javamail.listMessages("INBOX","",1,10);
request.debug(messageList);


But that's all I tried. Wrong username/pass throws "could not connect
to server, check host name", FYI.

Called it javamail.cfc so it'll eventually be <cfjavamail
action="blah" /> or whatnot on railoprojects maybe, assuming it's
cool.

Rick, wanna team up on this? FWIW, I have a UI somewhere that uses
dojo and is beautiful. CFOpenMail maybe?

:den

--
I am obliged to believe certain opinions myself. No man's belief will
save me except my own.
Anthony Collins

Reply all
Reply to author
Forward
0 new messages