Configuring Tomcat mail

The application sometimes sends emails to users, for example when the users are 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 in the $TOMCAT_HOME/conf/server.xml file.

<Resource auth="Container" name="mail/OpenKM" type="javax.mail.Session"
          mail.from="testing@openkm.com" mail.smtp.host="localhost" />

Change mail configuration

If your server does not require authentication you might remove the line mail.smtp.auth="true"

Get your mail account data (the same that would be used to configure a standard mail client, such as Outlook or Thunderbird).

Edit the file $TOMCAT_HOME/conf/server.xml:

vim /home/openkm/tomcat-7.0.61/conf/server.xml

After editing, the server.xml should look something like this:

<Resource name="mail/OpenKM" type="javax.mail.Session"
    mail.transport.protocol="smtp"
    mail.smtp.auth="true"
    mail.smtp.host="your smtp server"
    mail.smtp.user="<username>"
    password="<password>"
    mail.port="25"
    mail.debug="true"/> 

Gmail example

<Resource name="mail/OpenKM" auth="Container" type="javax.mail.Session"
    mail.transport.protocol="smtp"
    mail.smtp.auth="true"
    mail.smtp.host="smtp.gmail.com"
    mail.smtp.port="465"
    mail.smtp.user="<username>"
    password="<password>"
    mail.from="<sender email>"
    mail.smtp.quitwait="false"
    mail.smtp.starttls.enable="true"
    mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory"
    mail.debug="true"/>

Office 365

<Resource name="mail/OpenKM" auth="Container" type="javax.mail.Session"
    mail.transport.protocol="smtp"
    mail.smtp.starttls.enable="true"
    mail.smtp.auth="true"
    mail.smtp.host="smtp.office365.com"
    mail.smtp.port="587"
    mail.smtp.user="<username>"
    mail.from="<username>"
    password="<password>"
    mail.debug="true" />

Additional information

Optionally, you can use this attribute:

  • mail.user="<username>"

If you get problems during tomcat startup, you can try using the attribute 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 mail.smtp.user may be able to send messages, this means the user who appears in the "From" mail header.