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 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

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

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

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

After editing the server.xml should looks 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.smtp.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 these attributes :

  • mail.user="<username>"

If you get problems during tomcat startup, 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.