Configuring 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 bound to localhost.
These are the default values:
spring.mail.host=localhost
spring.mail.port=25
spring.mail.username=
spring.mail.password=
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 (the same as you would use to configure a standard mail client, like Outlook or Thunderbird).
Edit the file $TOMCAT_HOME/openkm.properties:
vim /home/openkm/tomcat-8.5.69/openkm.properties
After editing, the openkm.properties file should look something like this:
spring.mail.host=localhost
spring.mail.port=25
spring.mail.username=
spring.mail.password=
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.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.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
Email server with old SSL configuration
spring.mail.host=mail.myserver.com
spring.mail.port=465
spring.mail.username=<username>
spring.mail.password=<password>
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.ssl.enable=true
spring.mail.properties.mail.debug=true
Additional information
Optionally, you can use these attributes:
- spring.mail.user="<username>"
Be careful with spring.mail.test-connection because when enabled, if the mail server connection test fails, OpenKM won't start:
- spring.mail.test-connection=true
If you get problems during Tomcat startup, you 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 means the user who appears in the "From" mail header.
Testing configuration
Sometimes configuring mail can be complex and error-prone because there are many configuration parameters and many different mail servers. To ease this configuration, we have developed a utility called OKMMailChecker which helps you to test the mail configuration without the need to restart OpenKM, which takes time and makes it unavailable for users during these tests.
Usage
This utility can be downloaded from https://download.openkm.com and should be placed in the OpenKM directory where the openkm.properties file is located. Indeed, this utility will read the mail configuration from this file. This utility has several parameters which will be used to send the test mail:
- -f, --from: From used to send the test mail (required)
- -t, --to: To used to send the test mail (required)
- -a, --attachment: An optional file to be sent as an attachment
You can execute the utility this way:
$ java -jar OKMMailChecker.jar -f origin@openkm.com -t destination@openkm.com -a SampleFile.txt