I know this has come up with a few times before but its something I want to blog more for myself so I could easily refer to it when required.
By default, cfpop does not support ssl and if you are trying to access your gmail account via cfpop, you wouldnt be able to do so straight away because gmail requires you to access its mail server using ssl. There are a couple solutions around (which can be searched via Google) but the best I found was that you can force socketFactory’s class to use ssl (which is not the default behaviour).
Just add the following few lines of code before your cfpop tag call and that should do it! And dont forget to enable POP access in your gmail account first.
<cfset javaSystem = createObject("java", "java.lang.System") />
<cfset jProps = javaSystem.getProperties() />
<cfset jProps.setProperty("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory") />
<cfset jProps.setproperty("mail.pop3.port",995) />
<cfset jProps.setProperty("mail.pop3.socketFactory.port", 995) />
#1 by Steve Glachan on July 7, 2008 - 7:15 am
Quote
Thanks for this, just what I was looking for
. Works just fine.
#2 by Dan on July 26, 2008 - 6:15 pm
Quote
I think there is an error on the second line – isn’t javaSystemjavaSystemProps supposed to be javaSystemProps?
Dan
#3 by Anuj Gakhar on July 26, 2008 - 8:11 pm
Quote
Hi Dan, you are right. For some reason, the colored coder was messing up the variable name. I had to change the variable name to fix it. The post is updated now. Thanks.
#4 by Chinmay Garde on September 29, 2008 - 2:22 pm
Quote
Just what I was looking for. Excellent work !
#5 by Fabian on October 9, 2008 - 6:21 am
Quote
I was looking for this!! thanks!! Little question though: do I need to turn it off if I’m going to check another (non-SSL) mail afterwards? How do I do it?
Thanks again
#6 by Anuj Gakhar on October 9, 2008 - 9:22 am
Quote
@Fabian, good question. Honestly, I havent tried doing that. I would imagine that in the case of a non-SSL mail, you would have to turn it off as it changes the ports that are specific to gmail alone. And since its telling the socketFactory to use the ssl , that will need to change as well. So, I assume this will either have to be turned off or used with the correct values for another mail provider.
Hope that helps.
#7 by Michael on October 31, 2008 - 3:51 am
Quote
Hey Anuj,
I’m running into a
An exception occurred when setting up mail server parameters.
This exception was caused by: javax.mail.MessagingException: Connect failed; nested exception is: javax.net.ssl.SSLException: untrusted server cert chain.
while trying this. Any idea what I’m lacking ?
#8 by Anuj Gakhar on November 9, 2008 - 12:16 pm
Quote
@Michael, sorry for the late reply. Are you still having this problem or did you manage to sort it out?
#9 by Fabian on November 9, 2008 - 5:42 pm
Quote
Hi Anuj,
Just for the rest of us, in response to my question to turn it off, this is how I made it work:
javaSystem = createObject(“java”, “java.lang.System”);
javaSystemProps = javaSystem.getProperties();
//SSL Needed.
if(SSL){
javaSystemProps.setProperty(“mail.pop3.socketFactory.class”,”javax.net.ssl.SSLSocketFactory”);
javaSystemProps.setProperty(“mail.pop3.socketFactory.fallback”,”true”);
)
//TURN SSL OFF
else{
javaSystemProps.setProperty(“mail.pop3.socketFactory.class”,”");
}
That works!
Fabian
#10 by Michael Borbor on March 21, 2009 - 3:05 am
Quote
Hi Anuj, I was trying to get to my gmail account, but there’s an additional pickle my internet connection is behind a proxy, maybe you can point to a solution where I can configure cf to route the Pop3 through the Proxy?
Thanks.
Pingback: CFPOP and SSL | The Thinking Lemur
#11 by Tafazul Gani on December 1, 2009 - 3:23 am
Quote
Hi guys,
I keep getting the error javax.mail.internet.MimeMultipart@ade348 for some emails. There are no attachments or content displayed when this happends.
Anyone knows any work around for this..
Please assit, really need a work around urgently
#12 by Tom on January 31, 2010 - 3:14 am
Quote
Works like a charm. Thanks!
#13 by Sree on March 31, 2010 - 2:53 pm
Quote
Can you help with this Error.
javax.mail.MessagingException: Connect failed; nested exception is: java.net.ConnectException: Connection timed out: connect.