Coldfusion 8 cfmail to office365 emails

Hi Guys,

Can anyone help!

We're moving our email system from an old sbs exchange server hosted locally to using microsoft cloud or office365.

We've alway had Coldfusion send emails out through our server but now we're in the cloud we have to use a secure smtp connection on port 587 usinf tls.  I cannot get this to work in Coldfusion 8.  I've installed a developer edition of CF10 and it works fine but CF8 is a no go.  

Has any managed to get cfmail to work with office365?  
Is there any difference between cfmail in CF8 and CF10?  
Is the bit encryption different between the versions?

Thanks
LVL 1
Peter1985Asked:
Who is Participating?
 
_agx_Connect With a Mentor Commented:
We're getting beyond my knowledge of javamail but a brief search suggests a possible problem with a security certificate. But that's just a guess.
0
 
RickEpnetCommented:
Have you looked in the logs is there any information there?
Coldfusion8\logs\mail.log
0
 
_agx_Commented:
Are you using the useTLS setting? Can you post a sample of your mail code.

Adding to what Rick said, try enabling the debug setting. Log info is sent to a different location than the default, but it's *very* detailed:

YES: sends debugging output to standard output. By default, if the console window is unavailable, ColdFusion sends output to cf_root\runtime\logs\coldfusion-out.log on server configurations. On J2EE configurations, with JRun, the default location is jrun_home/logs/servername-out.log. Caution: If you set this option to yes, ColdFusion writes detailed debugging information to the log, including all message contents, and can generate large logs quickly.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Peter1985Author Commented:
I've attached the output from both log files and I've included the cfmail code.  The code works in CF10 but not in CF8.  The mail settings in the admin area are the same and so is the cfmail code.  Both CF servers are on the same network both behind the same firewall so I don't think anything is being blocked.

Has anyone successfully sent emails via exchange online?


02/01 16:36:38 Error [scheduler-9] - Can't send command to SMTP host

"Error","scheduler-9","02/01/13","16:36:38",,"Can't send command to SMTP host"

<cfmail
	to="<toAddress>"
	from="<fromAddress>"
	type="html"
	subject="test mail"
	server="pod51016.outlook.com"
	port="587"
	password="<password>"
	username="<fromAddress>"
	useTLS="yes">

Test Email

</cfmail>

Open in new window

0
 
_agx_Commented:
Doesn't look like you enabled the "debug" setting, because those logs show a LOT more detail. (Edit) Typically it records the whole back and forth conversation with the mail server, similar to the telnet output shown here. You can usually find the underlying problem by reviewing those logs.  

(Important:  Debug logs show everything - so obviously remove any confidential info before posting here.)
0
 
RickEpnetCommented:
Please setup the debug like _agx_ said but are you sure you have the user name and password formated correctly? Not sure how 360 works but I know sometimes with AD you have to use this format domain/username not sure is there is a certain format for 360.
0
 
Peter1985Author Commented:
Apologies here's the debug:

02/01 19:04:31 Information [scheduler-4] - Run Client Storage Purge
DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "pod51016.outlook.com", port 587, isSSL false
220 pod51016.outlook.com Microsoft ESMTP MAIL Service ready at Fri, 1 Feb 2013 19:07:36 +0000
DEBUG SMTP: connected to host "pod51016.outlook.com", port: 587

EHLO webserv
250-pod51016.outlook.com Hello [myIpAddress]
250-SIZE 36700160
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-AUTH
250-8BITMIME
250-BINARYMIME
250 CHUNKING
DEBUG SMTP: Found extension "SIZE", arg "36700160"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "AUTH", arg ""
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
STARTTLS
220 2.0.0 SMTP server ready
EHLO webserv
02/01 19:07:37 Error [scheduler-4] - Can't send command to SMTP host
02/01 19:07:37 Information [scheduler-4] - Moved undelivered mail: Mail60342.cfmail to C:\ColdFusion8/Mail/Undelivr directory
0
 
RickEpnetCommented:
How many messages are you trying to send at the same time? Also how big is the message you are trying to send?
0
 
Peter1985Author Commented:
I'm only trying to send one message which is very small. I've listed the code in a previous post.
0
 
_agx_Commented:
Is that the entire mail conversation from the logs? Usually there is something more, like the command that failed w/an error and and an error code.

Also, if you try the exact same mail in CF10, what does the debug conversation look like?  Anything different, like the mail provider or  the "isSSL false" setting?
0
 
Peter1985Author Commented:
Apologies...  I couldn't get the CF10 log until today which I've listed below.  Also, as far as I can tell that is all that was showing on the runtime debug log of CF8.


Feb 4, 2013 10:15:05 AM Information [catalina-exec-1] - HTTP request completed  {Status Code=200 ,Time taken=5616 ms}
DEBUG: setDebug: JavaMail version 1.4.4
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "pod51016.outlook.com", port 587, isSSL false
220 pod51016.outlook.com Microsoft ESMTP MAIL Service ready at Mon, 4 Feb 2013 10:15:34 +0000
DEBUG SMTP: connected to host "pod51016.outlook.com", port: 587

EHLO <testpc>
250-pod51016.outlook.com Hello [myIpAddress]
250-SIZE 36700160
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-AUTH
250-8BITMIME
250-BINARYMIME
250 CHUNKING
DEBUG SMTP: Found extension "SIZE", arg "36700160"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "AUTH", arg ""
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
STARTTLS
220 2.0.0 SMTP server ready
EHLO <testpc>
250-pod51016.outlook.com Hello [myIpAddress]
250-SIZE 36700160
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-AUTH LOGIN
250-8BITMIME
250-BINARYMIME
250 CHUNKING
DEBUG SMTP: Found extension "SIZE", arg "36700160"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Attempt to authenticate
DEBUG SMTP: check mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM
AUTH LOGIN
334 VXNlcm5hbWU6
cGV0ZXJiQHdvcmRmbG93LmNvLnVr
334 UGFzc3dvcmQ6
VzByZGZsMHcyNw==
235 2.7.0 Authentication successful
DEBUG SMTP: use8bit false
MAIL FROM:<myEmail>
250 2.1.0 Sender OK
DEBUG SMTP: sendPartial set
RCPT TO:<toEmail>
250 2.1.5 Recipient OK
DEBUG SMTP: Verified Addresses
DEBUG SMTP:   <toEmail>
DATA
354 Start mail input; end with <CRLF>.<CRLF>
Date: Mon, 4 Feb 2013 10:15:38 +0000 (GMT)
From: <fromEmail>
To: <toEmail>
Message-ID: <25594738.1.1359972938050.JavaMail.PETER-HPPC$@pod51016.outlook.com>
Subject: test mail
MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Mailer: ColdFusion 10 Application Server



Hello this is a test22
.
250 2.6.0 <25594738.1.1359972938050.JavaMail.PETER-HPPC$@pod51016.outlook.com> [InternalId=65233164] Queued mail for delivery
QUIT
221 2.0.0 Service closing transmission channel
0
 
Peter1985Author Commented:
The only thing that looks different to me is the JavaMail version.  Any ideas?
0
 
_agx_Commented:
> 02/01 19:07:37 Error [scheduler-4] - Can't send command to SMTP host
 
Yeah, looks the same to me too. The odd thing is it looks like the logger is swallowing the error trace. There should be the details of the exception, like your normal stack trace that occurs with any CF error.  Did you check the other log files in both the cf_root\logs and cf_root\runtime\ directories to see if they contain the error detail?  If not, try temporarily disabling spooling. That might spit out the full error on the page OR in the log files.
0
 
Peter1985Author Commented:
The logs show nothing more that what I've posted however, after disabling spool emails I get the following error message in the browser output.

A problem occurred when attempting to deliver mail.  
This exception was caused by: javax.mail.MessagingException: Can't send command to SMTP host; nested exception is: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.
0
 
Peter1985Author Commented:
Do you know if any of the coldfusion hot fix updates upgrade the javamail api?
0
 
_agx_Commented:
I'm not sure. But it's possible as CF includes a mail.jar in it's main directory of jars ie cf_root\lib\mail.jar
0
 
Peter1985Author Commented:
I've been reading that you can upgrade the jvm for Coldfusion but I have no idea how to do this and whether it will fix my problem. Still searching the web for answers.
0
 
_agx_Commented:
Well if the problem is certificates, I don't know that upgrading will solve it... Might try  and inspect the certificates on the machine.

However, upgrading CF the jvm isn't difficult.  Just be sure the version is compatible w/CF8. AFAIK, it's compatible w/java 1.6.x  but NOT java 1.7.

** Important: Always make a backup copy of  your jvm.config first. Don't skip this step!.  Reason is any change to jvm.config can potentially prevent the CF server from starting. As long as you have a backup copy, you just restore it and you're back in business.  So always play it safe and have a backup.  (The jvm.config file is usually found in: cf_root\runtime\bin\jvm.config.)

Anyway, to update the JVM used by CF:

1) Download and install java to external directory like c:\program files\java\xxxx
2) Log into the CF Admin and go to Server Settings > Java & JVM. Change the path so it points to the new version of java
3) Reboot the CF server

That's it.  For more details
http://helpx.adobe.com/coldfusion/kb/change-jvm-coldfusion-jrun.html
0
 
Peter1985Author Commented:
Before updating the jvm I decided to install a copy of CF8 on another PC and the CFmail works.  There I believe your right and it is a certificate issue.  I ran openssl on both machines with the command in the link you sent but not really sure what I'm looking for (they both looked identical).

Is there a way to restore CF8's certificates back to default or are the certs more to do with the PC/OS?  I think I'm out of my depth here.
0
 
_agx_Commented:
In terms of CF, certificates are related to the jvm. Certificate info is usually stored in a "keystore" file named cacerts.  ie {jre}\lib\security\cacerts.  

Is there a way to restore CF8's certificates back to default or are the certs more to do with the PC/OS?  I think I'm out of my depth here.

We're getting out of my comfort zone too. I *think* you could restore the defaults by overwriting the "cacerts". BUT ... a) its usually password protected and b) I don't know what effect that would have on your server beyond wiping out all existing certificate info.  So I'd strongly recommend asking a java person.   Sorry I couldn't be of more help on this.  

http://docs.oracle.com/javase/1.5.0/docs/tooldocs/solaris/keytool.html
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WS5AFDEFD4-2851-4a09-A627-7D82974E5EAC.html
0
 
Peter1985Author Commented:
I've now managed to get it working.  I copied the cacerts file from the test server and restarted the cf services and it now works.  I have to import any additional certs again but it seems to be working.  Thanks for all your help with this.
0
 
_agx_Commented:
Glad to hear it.  Just be sure to reset the cacert password(s) so you're not still using the default which is very insecure (I think it's something like "changeit").
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.