Emails not sending through Office 365 but works through Gmail

January 27, 2019
Newbie 1 posts
Followers: 0 people
3

Emails not sending through Office 365 but works through Gmail

Newbie 1 posts
Followers: 0 people
January 27, 2019

I’m moving all my sites to a new server and the new server will not send cfmail through Office365 SMTP. It works when I send using a Gmail account. I’m using the exact same code and the ColdFusion admin setting are the same. Old Server Windows 2008. New Server Windows 2012. Both using ColdFusion 2016 (all updates installed).

This is the error message in the mail error log. I’m guessing it has something to do with TTL.

com.sun.mail.util.MailConnectException: Couldn’t connect to host, port: smtp.office365.com, 587; timeout 60000; nested exception is: java.net.SocketException: Permission denied: connect

<cfmail from=”noreply@mydomain.com”
to=”me@mydomain.com”
subject=”Test Email”
type=”html”
port=”587″
useTLS=”true”
server=”smtp.office365.com”
username=”noreply@mydomain.com”
password=”mypassword”>
Test message
</cfmail>

This works:
<cfmail from=”service@anotherdomain.com”
to=”me@mydomain.com”
subject=”Google Mail”
type=”html”
server=”smtp.gmail.com”
port=”465″
useSSL=”true”
username=”service@anotherdomain.com”
password=”thepassword”>
Test Message
</cfmail>

Comments (3)
2019-01-29 13:07:46
2019-01-29 13:07:46

Thanks for the replies. I figured it out. The antivirus software was blocking the mail.

Like
2019-01-29 07:48:31
2019-01-29 07:48:31

From the exception, it seems like the server is not able to connect to office365 on port 587.

You can try invoking telnet <ip> <port> to see if it is working. If Telnet could not connect, it would say connection failed, which means your firewall is blocking the port.

Like
2019-01-28 18:23:03
2019-01-28 18:23:03

Check to make sure the user is allowed to send via SMTP. Your admin might have those permissions denied by default.

Like
Add your comment