Configuring Tomcat mail

The application sometimes sends emails to users, for example when the users have been subscribed to a document or folder.

By default tomcat mail is configured assuming your server has a mail service binding in your localhost.

This is the default value:

spring.mail.host=localhost
spring.mail.port=25
spring.mail.username=none
spring.mail.password=none
spring.mail.from=noreply@openkm.com
spring.mail.properties.mail.smtp.auth=false
spring.mail.properties.mail.smtp.starttls.enable=false

Change mail configuration

Get your mail account data ( same than you will use to configure standard mail client, like Outlook or Thunderbird ).

Edit the file $TOMCAT_HOME/openkm.properties:  

vim /home/openkm/tomcat-8.5.24/openkm.properties

After editing the server.xml should looks something like this:

spring.mail.host=localhost
spring.mail.port=25
spring.mail.username=none
spring.mail.password=none
spring.mail.from=noreply@openkm.com
spring.mail.properties.mail.smtp.auth=false
spring.mail.properties.mail.smtp.starttls.enable=false

Gmail example

spring.mail.test-connection=true
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=<username>
spring.mail.password=<password>
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.ssl.trust=smtp.gmail.com
spring.mail.properties.mail.debug=true

Office 365

spring.mail.test-connection=true
spring.mail.host=smtp.office365.com
spring.mail.username=<username>
spring.mail.password=<password>
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.ssl.trust=smtp.office365.com
spring.mail.properties.mail.debug=true

Additional information

Optionally, you can use these attributes :

  • spring.mail.user="<username>"

If you get problems during tomcat startup, can try using the attribute spring.mail.smtp.quitwait="false".

A complete list of all available parameters can be found at sun.mail.smtp package Javadoc and javax.mail package Javadoc.

Note that depending on the SMTP server configuration only the address configured in spring.mail.smtp.user may be able to send messages, this mean, the user who appears in the "From" mail header.