Smtp

Sends an e-mail to the configured destination(s).

Configuration

Legend:

  • required

  • optional

  • may use environment variable

  • accepts Name Templates

  • YAML

  • TOML

  • JSON

  • Maven

  • Gradle

announce:
  # 
  smtp:

    # Enable or disable this announcer.
    # Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
    # Defaults to `NEVER`.
    #  
    active: ALWAYS

    # Additional properties used when evaluating templates.
    #  
    extraProperties:
      # Key will be capitalized and prefixed with `smtp`, i.e, `smtpFoo`.
      foo: bar

    # The e-mail transport.
    # Supported values are: [SMTP, SMTPS].
    # Defaults to SMTP.
    # 
    transport: SMTP

    # The mime-type of the message to be sent.
    # Supported values are: [TEXT, HTML].
    # Defaults to TEXT.
    # 
    mimeType: TEXT

    # The port where the smtp server listens to incoming messages.
    # 
    port: 25

    # Whether authentication is required or not.
    # If set to `true` then both `username` and `password` must be set.
    # Defaults to `false`.
    # 
    auth: true

    # The address of the SMTP server, e.g. 'smtp.gmail.com'.
    # 
    host: smtp.gmail.com

    # The username required for authentication.
    #  Only if auth = `true`.
    username: duke

    # The password associated with the given username.
    #  Only if auth = `true`. 
    password: __USE_ENVIRONMENT_VARIABLE__

    # The message sender, i.e, `duke@jreleaser.org`.
    # 
    from: duke@jreleaser.org

    # The message recipient(s).
    # Multiple addresses may be specified as a comma-separated list.
    # 
    to: announce@acme.com

    # The CC recipient(s).
    # Multiple addresses may be specified as a comma-separated list.
    # 
    cc: additional@acme.com

    # The BCC recipient(s).
    # Multiple addresses may be specified as a comma-separated list.
    # 
    bcc: hidden@acme.com

    # The messages' subject.
    # Review the available Name Templates.
    #  
    subject: '{{projectNameCapitalized}} {{projectVersion}} released!'

    # The announcement message.
    # Review the available Name Templates.
    #  
    message: |
      We just launched {{projectNameCapitalized}} {{projectVersion}}!
      {{changelog}}

    # Path to a template file that contains the message.
    # Review the available Name Templates.
    # Defaults to `src/jreleaser/templates/smtp.tpl`.
    # 
    messageTemplate: path/to/template/smtp.tpl

    # Additional smtp properties to be configured.
    # Use this field to set properties such as `mail.smtp.starttls.enable`.
    # 
    properties:
      'mail.smtp.starttls.enable': true
# 
[announce.smtp]

  # Enable or disable this announcer.
  # Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
  # Defaults to `NEVER`.
  #  
  active = "ALWAYS"

  # Additional properties used when evaluating templates.
  #  
  extraProperties.foo = "bar"
  # Key will be capitalized and prefixed with `smtp`, i.e, `smtpFoo`.

  # The e-mail transport.
  # Supported values are: [SMTP, SMTPS].
  # Defaults to SMTP.
  # 
  transport = "SMTP"

  # The mime-type of the message to be sent.
  # Supported values are: [TEXT, HTML].
  # Defaults to TEXT.
  # 
  mimeType = "TEXT"

  # The port where the smtp server listens to incoming messages.
  # 
  port = "25"

  # Whether authentication is required or not.
  # If set to `true` then both `username` and `password` must be set.
  # Defaults to `false`.
  # 
  auth = true

  # The address of the SMTP server, e.g. 'smtp.gmail.com'.
  # 
  host = "smtp.gmail.com"

  # The username required for authentication.
  #  Only if auth = `true`.
  username = "duke"

  # The password associated with the given username.
  #  Only if auth = `true`. 
  password = "__USE_ENVIRONMENT_VARIABLE__"

  # The message sender, i.e, `duke@jreleaser.org`.
  # 
  from = "duke@jreleaser.org"

  # The message recipient(s).
  # Multiple addresses may be specified as a comma-separated list.
  # 
  to = "announce@acme.com"

  # The CC recipient(s).
  # Multiple addresses may be specified as a comma-separated list.
  # 
  cc = "additional@acme.com"

  # The BCC recipient(s).
  # Multiple addresses may be specified as a comma-separated list.
  # 
  bcc = "hidden@acme.com"

  # The messages' subject.
  # Review the available Name Templates.
  #  
  subject = "{{projectNameCapitalized}} {{projectVersion}} released!"

  # The announcement message.
  # Review the available Name Templates.
  #  
  message = """
    We just launched {{projectNameCapitalized}} {{projectVersion}}!
    {{changelog}}"""

  # Path to a template file that contains the message.
  # Review the available Name Templates.
  # Defaults to `src/jreleaser/templates/smtp.tpl`.
  # 
  messageTemplate = "path/to/template/smtp.tpl"

  # Additional smtp properties to be configured.
  # Use this field to set properties such as `mail.smtp.starttls.enable`.
  # 
  properties."mail.smtp.starttls.enable" = "true"
{
  announce: {
    // 
    "smtp": {

      // Enable or disable this announcer.
      // Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
      // Defaults to `NEVER`.
      //  
      "active": "ALWAYS",

      // Additional properties used when evaluating templates.
      //  
      "extraProperties": {
        // Key will be capitalized and prefixed with `smtp`, i.e, `smtpFoo`.
        "foo": "bar"
      },

      // The e-mail transport.
      // Supported values are: [SMTP, SMTPS].
      // Defaults to SMTP.
      // 
      "transport": "SMTP",

      // The mime-type of the message to be sent.
      // Supported values are: [TEXT, HTML].
      // Defaults to TEXT.
      // 
      'mimeType': "TEXT",

      // The port where the smtp server listens to incoming messages.
      // 
      "port": 25,

      // Whether authentication is required or not.
      // If set to `true` then both `username` and `password` must be set.
      // Defaults to `false`.
      // 
      "auth": true,

      // The address of the SMTP server, e.g. 'smtp.gmail.com'.
      // 
      "host": "smtp.gmail.com",

      // The username required for authentication.
      //  Only if auth = `true`.
      "username": "duke",

      // The password associated with the given username.
      //  Only if auth = `true`. 
      "password": "__USE_ENVIRONMENT_VARIABLE__",

      // The message sender, i.e, `duke@jreleaser.org`.
      // 
      "from": "duke@jreleaser.org",

      // The message recipient(s).
      // Multiple addresses may be specified as a comma-separated list.
      // 
      "to": "announce@acme.com",

      // The CC recipient(s).
      // Multiple addresses may be specified as a comma-separated list.
      // 
      "cc": "additional@acme.com",

      // The BCC recipient(s).
      // Multiple addresses may be specified as a comma-separated list.
      // 
      "bcc": "hidden@acme.com",

      // The messages' subject.
      // Review the available Name Templates.
      //  
      "subject": "{{projectNameCapitalized}} {{projectVersion}} released!",

      // The announcement message.
      // Review the available Name Templates.
      //  
      "message": "We just launched {{projectNameCapitalized}} {{projectVersion}}!\\n{{changelog}}",

      // Path to a template file that contains the message.
      // Review the available Name Templates.
      // Defaults to `src/jreleaser/templates/smtp.tpl`.
      // 
      "messageTemplate": "path/to/template/smtp.tpl"

      // Additional smtp properties to be configured.
      // Use this field to set properties such as `mail.smtp.starttls.enable`.
      // 
      "properties": {
        "mail.smtp.starttls.enable": true
      }
    }
  }
}
<jreleaser>
  <!--
    
  -->
  <announce>
    <!--
      
    -->
    <smtp>
      <!--
        Enable or disable this announcer.
        Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
        Defaults to `NEVER`.
         
      -->
      <active>ALWAYS</active>

      <!--
        Additional properties used when evaluating templates.
         
      -->
      <extraProperties>
        <!--
          Key will be capitalized and prefixed with `smtp`, i.e, `smtpFoo`.
        -->
        <foo>bar</foo>
      </extraProperties>

      <!--
        The e-mail transport.
        Supported values are: [SMTP, SMTPS].
        Defaults to SMTP.
        
      -->
      <transport>SMTP</transport>

      <!--
        The mime-type of the message to be sent.
        Supported values are: [TEXT, HTML].
        Defaults to TEXT.
        
      -->
      <mimeType>TEXT</mimeType>

      <!--
        The port where the smtp server listens to incoming messages.
        
      -->
      <port>25</port>

      <!--
        Whether authentication is required or not.
        If set to `true` then both `username` and `password` must be set.
        Defaults to `false`.
        
      -->
      <auth>true</auth>

      <!--
        The address of the SMTP server, e.g. 'smtp.gmail.com'.
        
      -->
      <host>smtp.gmail.com</host>

      <!--
        The username required for authentication.
         Only if auth = `true`.
      -->
      <username>duke</username>

      <!--
        The password associated with the given username.
         Only if auth = `true`. 
      -->
      <password>__USE_ENVIRONMENT_VARIABLE__</password>

      <!--
        The message sender, i.e, `duke@jreleaser.org`.
        
      -->
      <from>duke@jreleaser.org</from>

      <!--
        The message recipient(s).
        Multiple addresses may be specified as a comma-separated list.
        
      -->
      <to>announce@acme.com</to>

      <!--
        The CC recipient(s).
        Multiple addresses may be specified as a comma-separated list.
        
      -->
      <cc>additional@acme.com</cc>

      <!--
        The BCC recipient(s).
        Multiple addresses may be specified as a comma-separated list.
        
      -->
      <bcc>hidden@acme.com</bcc>

      <!--
        The messages' subject.
        Review the available Name Templates.
         
      -->
      <subject>{{projectNameCapitalized}} {{projectVersion}} released!</subject>

      <!--
        The announcement message.
        Review the available Name Templates.
         
      -->
      <message>
        We just launched {{projectNameCapitalized}} {{projectVersion}}!
        {{changelog}}
      </message>

      <!--
        Path to a template file that contains the message.
        Review the available Name Templates.
        Defaults to `src/jreleaser/templates/smtp.tpl`.
        
      -->
      <messageTemplate>path/to/template/smtp.tpl</messageTemplate>

      <!--
        Additional smtp properties to be configured.
        Use this field to set properties such as `mail.smtp.starttls.enable`.
        
      -->
      <properties>
        <mail.smtp.starttls.enable>true</mail.smtp.starttls.enable>
      </properties>
    </smtp>
  </announce>
</jreleaser>
jreleaser {
  announce {
    // 
    smtp {

      // Enable or disable this announcer.
      // Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
      // Defaults to `NEVER`.
      //  
      active = 'ALWAYS'

      // Additional properties used when evaluating templates.
      // Key will be capitalized and prefixed with `smtp`, i.e, `smtpFoo`.
      //  
      extraProperties.put('foo', 'bar')

      // The e-mail transport.
      // Supported values are = [SMTP, SMTPS].
      // Defaults to SMTP.
      // 
      transport = 'SMTP'

      // The mime-type of the message to be sent.
      // Supported values are = [TEXT, HTML].
      // Defaults to TEXT.
      // 
      mimeType = 'TEXT'

      // The port where the smtp server listens to incoming messages.
      // 
      port = 25

      // Whether authentication is required or not.
      // If set to `true` then both `username` and `password` must be set.
      // Defaults to `false`.
      // 
      auth = true

      // The address of the SMTP server, e.g. 'smtp.gmail.com'.
      // 
      host = 'smtp.gmail.com'

      // The username required for authentication.
      //  Only if auth = `true`.
      username: 'duke'

      // The password associated with the given username.
      //  Only if auth = `true`.v 
      password = '__USE_ENVIRONMENT_VARIABLE__'

      // The message sender, i.e, `duke@jreleaser.org`.
      // 
      from = 'duke@jreleaser.org'

      // The message recipient(s).
      // Multiple addresses may be specified as a comma-separated list.
      // 
      to = 'announce@acme.com'

      // The CC recipient(s).
      // Multiple addresses may be specified as a comma-separated list.
      // 
      cc = 'additional@acme.com'

      // The BCC recipient(s).
      // Multiple addresses may be specified as a comma-separated list.
      // 
      bcc = 'hidden@acme.com'

      // The messages' subject.
      // Review the available Name Templates.
      //  
      subject = '{{projectNameCapitalized}} {{projectVersion}} released!'

      // The announcement message.
      // Review the available Name Templates.
      //  
      message = '''
        We just launched {{projectNameCapitalized}} {{projectVersion}}!
        {{changelog}}'''

      // Path to a template file that contains the message.
      // Review the available Name Templates.
      // Defaults to `src/jreleaser/templates/smtp.tpl`.
      // 
      messageTemplate = 'path/to/template/smtp.tpl'

      // Additional smtp properties to be configured.
      // Use this field to set properties such as `mail.smtp.starttls.enable`.
      // 
      properties.put('mail.smtp.starttls.enable', 'true')
    }
  }
}
At least one of to, cc, or bcc must be specified.

You may define either message or messageTemplate, with the former taking precedence over the latter.

The following smtp properties will be set by default given these conditions:

SMTP transport
mail.smtp.starttls.enable

Set to true if not present and auth is set to true.

SMTPS transport
mail.smtp.socketFactory.port

Set to port if not present and auth is set to true.

mail.smtp.socketFactory.class

Set to javax.net.ssl.SSLSocketFactory if not present and auth is set to true.

Environment

When not explicitly set, the value of the following properties may be resolved from an environment variable or a system property as shown in the table. The system property takes precedence over the environment variable.

System Property Environment Variable

active

jreleaser.announce.smtp.active

JRELEASER_ANNOUNCE_SMTP_ACTIVE

password

jreleaser.announce.smtp.password
jreleaser.smtp.password
jreleaser.mail.password

JRELEASER_ANNOUNCE_SMTP_PASSWORD
JRELEASER_SMTP_PASSWORD
JRELEASER_MAIL_PASSWORD

Sending mail via Gmail

If you setup smtp.gmail.com as your mail server you may encounter an exception similar to

Caused by: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8  https://support.google.com/mail/?p=BadCredentials bj7sm9598226ejb.28 - gmail

If you do then it means your account cannot be used as is to sent messages via Gmail. You may need to create an App Password and set it as the value for password (remember to use the JRELEASER_SMTP_PASSWORD environment variable instead).

It may be the case that GSmtp decides there’s a different way to allow access to your account, in which case review GSmtp’s guidelines and adjust your configuration accordingly.

Templates

The default location for templates is:

src/jreleaser/templates

The following list shows the filenames that may be used to override default templates:

  • smtp.tpl

Templates may be initialized using the template command