Skip to main content

Enabling email notifications

Set up SMTP

To set up email notifications for an on-prem build, you must pass environment variables or extend application properties with the following:

  1. SMTP server settings
    • spring.mail.host (SPRING_MAIL_HOST) - SMTP server host (for example, "smtp.google.com", "email-smtp.us-west-2.amazonaws.com", or "smtp.postmarkapp.com")
    • spring.mail.port (SPRING_MAIL_PORT) - SMTP server port (for example, 25, 465, or 587)
  2. Authorization
    • spring.mail.username (SPRING_MAIL_USERNAME) - SMTP server username
    • spring.mail.password (SPRING_MAIL_PASSWORD) - SMTP server password
    • spring.mail.properties.mail.smtp.auth (SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH) - true
  3. SSL
    • spring.mail.properties.mail.smtp.starttls.enable (SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE) - true

For example, using google SMTP server with SSL should look like this:

spring.mail.host=smtp.google.com
spring.mail.port=587
spring.mail.username=xxx
spring.mail.password=xxx
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true

With environment variables:

SPRING_MAIL_HOST=smtp.google.com
SPRING_MAIL_PORT=587
SPRING_MAIL_USERNAME=xxx
SPRING_MAIL_PASSWORD=xxx
SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH=true
SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE=true

Set up from & reply-to addresses

To set up email notifications, it is required to set up a "from" address and, optionally, a "reply-to" address. To do that:

  • notifications.email.from (NOTIFICATIONS_EMAIL_FROM) - valid email address to be used as a sender address
  • notifications.email.replyTo (NOTIFICATIONS_EMAIL_REPLY_TO) - valid email address to be used as a reply-to address

For example this is what Cortex uses for its notifications:

notifications.email.from=Cortex Notifications <product@notifications.cortex.io>
notifications.email.replyTo=no-reply@cortex.io

With environment variables:

NOTIFICATIONS_EMAIL_FROM=Cortex Notifications <product@notifications.cortex.io>
NOTIFICATIONS_EMAIL_REPLY_TO=no-reply@cortex.io