[SOLVED] JavaMail not working with Office 365

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.
Post Reply
dferguson
Expert Boarder
Expert Boarder
Posts: 120
Joined: Thu May 18, 2017 12:48 pm

[SOLVED] JavaMail not working with Office 365

Post by dferguson » Fri Feb 01, 2019 7:52 pm

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.

dferguson
Expert Boarder
Expert Boarder
Posts: 120
Joined: Thu May 18, 2017 12:48 pm

Re: JavaMail not working with Office 365

Post by dferguson » Fri Feb 01, 2019 8:50 pm

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

jllort
Moderator
Moderator
Posts: 10929
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: JavaMail not working with Office 365

Post by jllort » Sat Feb 02, 2019 7:16 pm

Seems is working.

dferguson
Expert Boarder
Expert Boarder
Posts: 120
Joined: Thu May 18, 2017 12:48 pm

Re: JavaMail not working with Office 365

Post by dferguson » Mon Feb 04, 2019 12:50 pm

Code: Select all

DEBUG SMTP: AUTH LOGIN failed
credentials are correct but I still get this...

jllort
Moderator
Moderator
Posts: 10929
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: JavaMail not working with Office 365

Post by jllort » Thu Feb 07, 2019 7:07 pm

I have updated the documentation section with a configuration what sure it is working https://docs.openkm.com/kcenter/view/ok ... -mail.html

dferguson
Expert Boarder
Expert Boarder
Posts: 120
Joined: Thu May 18, 2017 12:48 pm

Re: JavaMail not working with Office 365

Post by dferguson » Thu Feb 07, 2019 8:32 pm

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"

Post Reply