Cfpop for gmail - Help Please
Hello, Please help with this error :
Error Message
Type: Application
Message: An exception occurred when setting up mail server parameters.
Detail: This exception was caused by: javax.mail.MessagingException: Connect failed; nested exception is: java.net.ConnectException: Connection timed out: connect.
Here is the Code :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Read gmail</title>
<style type="text/css">
body {font-family: Verdana,sans-serif}
.error {color: #f00;}
</style>
</head>
<body>
<cfoutput>
<!--- Directory for attachment files --->
<cfset attachmentFolder = ExpandPath("attachments") />
<!--- Array for attachment name(s) --->
<cfset attachmentNameArray = ArrayNew(1) />
<!--- Array for attachment file(s) --->
<cfset attachmentFileArray = ArrayNew(1) />
<h1>Gmail</h1>
<form action="gmail.cfm" method="post">
<p><label for="popserver">Mail server:</label><br />
<input id="popserver" type="Text" name="popserver" value="pop.gmail.com" /></p>
<p><label for="username">Username:</label><br />
<input id="username" type="Text" name="username" />
<p><label for="pwd">Password:</label><br />
<input type="password" name="pwd" /></p>
<input type="Submit" name="get email" value="Get E-mail" />
</form>
<cfif IsDefined("form.popserver")>
<!--- make sure server, username are not empty --->
<cfif form.popserver is not "" and form.username is not "">
<!--- Turn on SSL --->
<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) />
<cflock name="cfpop-#form.username#" type="exclusive" timeout="50">
<cftry>
<cfpop server="#form.popserver#" username="#form.username#" password="#form.pwd#"
action="getAll" name="getEmail" attachmentpath="#attachmentFolder#" generateUniqueFilenames="true">
<cfcatch type="any">
<h2 class="error">Error Message</h2>
<p><strong>Type:</strong> #CFCATCH.Type#</p>
<p><strong>Message:</strong> #CFCATCH.Message#</p>
<p><strong>Detail:</strong> #CFCATCH.Detail#</p>
<cfabort>
</cfcatch>
</cftry>
</cflock>
<h2>Messages</h2>
<p><strong>Number of Records:</strong> #getEmail.recordCount#</p>
<p><strong>FYI - TempDirectory:</strong> #GetTempDirectory()#</p>
<ul>
<cfloop from="#getEmail.recordCount#" to="1" step="-1" index="i">
<li><strong>Row: #i#</strong><br />
<em>MessageNumber:</em> #getEmail.messagenumber#<br />
<em>UID:</em> #getEmail.UID#<br />
<em>From:</em> #getEmail.From#<br />
<em>Subject:</em> #getEmail.Subject#<br />
<em>Message:</em> #getEmail.body#<br />
<cfif Len(getEmail.attachments)>
<cfset attachmentNameArray = ListtoArray(getEmail.attachments, chr(9)) />
<cfset attachmentFileArray = ListtoArray(getEmail.attachmentfiles, chr(9)) />
<em>Attachments:</em><br />
<cfloop from="1" to="#ArrayLen(attachmentNameArray)#" index="num">
#attachmentNameArray[num]#<br />
</cfloop>
<em>Attachment Files Server Location:</em><br />
<cfloop from="1" to="#ArrayLen(attachmentFileArray)#" index="num">
#attachmentFileArray[num]#<br />
</cfloop>
</cfif>
</li>
</cfloop>
</ul>
<!--- Turn off SSL --->
<!--- <cfset jProps.setProperty("mail.pop3.socketFactory.class", "javax.net.SocketFactory") /> --->
</cfif>
</cfif>
Thanks in advance,
Sree
</cfoutput>
</body>
</html>
