• [SOLVED] JavaMail not working with Office 365

  • OpenKM has many interesting features, but requires some configuration process to show its full potential.
OpenKM has many interesting features, but requires some configuration process to show its full potential.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #47385  by dferguson
 
I have successfully used the tomcat mail with gmail before, but this installation requires me to use our Office 365 account.

Here is my server.xml file section for mail configuration.
Code: Select all
<Resource name="mail/OpenKM"
		auth="Container" type="javax.mail.Session"
		mail.transport.protocol="smtp"
		mail.smtp.host="smtp.office365.com"
		mail.smtp.from="Docs@example.net"
		mail.smtp.username="Docs"
		mail.smtp.password="password"
		mail.smtp.port="587"
		mail.smtp.startttls.enable="true"
		mail.debug="true"
		mail.smtp.auth="true"/>
However, I keep getting this when trying to check the email function from the admin panel.

Code: Select all
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: need username and password for authentication
Last edited by dferguson on Fri Feb 08, 2019 1:09 pm, edited 1 time in total.
 #47386  by dferguson
 
I cleaned up my config settings to:
Code: Select all
<Resource name="mail/OpenKM"
		type="javax.mail.Session"
		mail.transport.protocol="smtp"
		mail.smtp.auth="true"
		mail.smtp.host="smtp.office365.com"
		mail.smtp.user="Docs"
		password="password"
		mail.smtp.port="587"
		mail.smtp.starttls.enable="true"
		mail.debug="true"
		/>
and now I get this...
Code: Select all
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
DEBUG SMTP: need username and password for authentication
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "smtp.office365.com", port 587, isSSL false
220 BN7PR02CA0012.outlook.office365.com Microsoft ESMTP MAIL Service ready at Fri, 1 Feb 2019 20:35:45 +0000
DEBUG SMTP: connected to host "smtp.office365.com", port: 587

EHLO dferguson-virtual-machine
250-BN7PR02CA0012.outlook.office365.com Hello [47.44.209.114]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 SMTPUTF8
DEBUG SMTP: Found extension "SIZE", arg "157286400"
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 "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Found extension "SMTPUTF8", arg ""
STARTTLS
220 2.0.0 SMTP server ready
EHLO dferguson-virtual-machine
250-BN7PR02CA0012.outlook.office365.com Hello [47.44.209.114]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-AUTH LOGIN XOAUTH2
250-8BITMIME
250-BINARYMIME
250-CHUNKING
250 SMTPUTF8
DEBUG SMTP: Found extension "SIZE", arg "157286400"
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 XOAUTH2"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Found extension "SMTPUTF8", arg ""
DEBUG SMTP: Attempt to authenticate using mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM 
DEBUG SMTP: AUTH LOGIN command trace suppressed
DEBUG SMTP: AUTH LOGIN failed
 #47424  by dferguson
 
Great!

You might clarify that as indicated by the Office 365 Javadocs link provided in the OpenKM documentation, the username would be:
Code: Select all
mail.smtp.user="example@yourdomain.com"
mail.smtp.from="example@yourdomain.com"

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.