Skip to content
OpenCms documentation
OpenCms documentation

Mail configuration

Overview of mail related system configuration options.

How to set up mail servers.

Customization of system mails.

Mail server configuration is done via the WEB-INF/config/opencms-system.xml configuration file.

Search for the <mail> element and add a configuration like the following:

Example

<mail>
  <mailfrom>noreply@example.com</mailfrom>
  <mailhost id="system"
            mailfrom="noreply1@example.de"
            name="mail@example.com"
            port="25"
            order="10"
            protocol="smtp"
            user="user1@mail@example.com"
            password="password"/>
  <mailhost id="dkim"
            mailfrom="noreply2@example.de"
            name="mail@example.com"
            port="25"
            order="20"
            protocol="smtp"
            user="user2@mail@example.com"
            password="password"/>
</mail>

As can be seen, multiple named mail servers can be configured using their ID attribute as their name.

The mail server with the ID “system” is used as default for internal system emails, e.g., when workplace users request a new password or when sending emails containing the log-in details for newly created workplace users.

If no mail host with the ID “system” exists, the first mail host is selected, with the ordering determined by the order attribute.

Additional mail servers with individual IDs can be configured, for example, to use a decided mail server with special DKIM settings for sending newsletters.

In the Java API, applications can access a specific mail host with the OpenCms.getSystemInfo().getMailSettings().getMailHost(“dkim”) function. The default mail host can be reached with OpenCms.getSystemInfo().getMailSettings().getDefaultMailHost().

The attributes name, port, protocol, user, security and password form the mail server access data.

The additional attribute called “security,” which can take the values “SSL” or “TLS”, is needed for mail servers that require these security protocols only.

The mailfrom attribute is an important fallback if an application has not set its own sending address. The <mailfrom> element is an additional fallback for email hosts that have not set a mailfrom attribute.

Java applications that rely on this method of configuring a mail server use the org.opencms.mail.CmsSimpleMail and org.opencms.mail.CmsHtmlMail classes, which can accept an org.opencms.mail.CmsMailHost parameter in their constructors.

The contents of the system mails sent when requesting for a new password, for example, are stored below the VFS folder /system/config/notification/.

The configuration file /system/config/notification/password-new-user-notification, for example, contains the welcome mail sent when a new workplace user has been registered.

If you want to customize those configuration files, e.g., by adding more locales than "de" and "en", or by adding your companies mail footer, proceed as follows:

  • Create a new folder /system/config/overrides/notification/.
  • Copy the original file to customize into this folder, e.g., to /system/config/overrides/notification/password-new-user-notification

If there is a configuration file with the same name found in the /overrides/notification subfolder, it is preferred over the original configuration file.