Send a custom email (non-issue events)
Use this listener to send an email based on a Jira non-issue event and custom condition. Non-issue events include:
Create a project
Add a new user
Update a component
Third-party plugin events
This listener is similar to the Send a Custom Email listener and Send a Custom Email post function.
This listener has multiple elements to it:
- Applied to: Choose if you want to apply this listener to specific or all projects in your instance.
- Events: Choose the non-issue event/s this listener will fire on.
- Condition and configuration: Set a condition to control when this listener fires. You can also pass additional variables to the body and subject templates using the
config
map, and dynamically control recipients using themail
variable. See Send a custom email for more information on configuring custom emails. - Email template: Write an email template using plain text or the GStringTemplateEngine.
- Subject template: Write the subject template using plain text or the GStringTemplateEngine.
- Email format: Choose whether to send the email as plain text or HTML.
- To addresses/To Groups: Choose who to send the email to.
CC addresses/CC Groups: Choose who should be CC'd on the email.
- Reply-to email address: Set the email address for replies.
Prerequisite
You must configure an SMTP mail server to send mail.
Condition and configuration example
In the Condition and configuration code editor you can enter a condition to ensure certain conditions are met before the email is sent. You can also use this code editor to pass additional variables to the Email template and Subject template using the config
map, and dynamically control recipients using the mail
variable. For example, we want to send an email after a version is released. In this example, the selected event will be VersionReleaseEvent
and the script in the Condition and Configuration field will be:
groovyimport com.atlassian.jira.event.project.VersionReleaseEvent def versionReleaseEvent = event as VersionReleaseEvent def version = versionReleaseEvent.version // Store in the config map, the version and the project name so we can use them later in our templates config.'versionName' = version.name config.'projectName' = version.project.name true
We can use the above variables in our Email and Subject and templates, for example the Email template would be:
groovyVersion $config.versionName for project $projectName just released. Congratulations!
Use this listener
- Navigate to ScriptRunner.
- Select Listeners > Create Listener.
- Select Send custom email (non-issue events).
- Enter a name that describes the listener (this name is for your reference when viewing all listeners).
- Enter the project(s) this listener will be applied to.
- Enter the event(s) this listener will fire on.
Optional: Enter a condition and any configuration you require. If no condition is specified, then this listener will always run on the chosen event/s.
You can pass additional variables to the body and subject template using the
config
map, and dynamically control recipients using themail
variable.- Write an email template. This can be written in plain text or you can use the GStringTemplateEngine.
- Write the subject template. This can be written in plain text or you can use the GStringTemplateEngine.
- Select the email format you want to send the email as.
- Enter whom you want to send the email to in To addresses and/or To groups.
- Enter whom you want to CC the email to in CC addresses and/or CC groups.
- Enter a reply-to email address.
Select Preview to see an overview of the configuration.
If you are facing issues with characters appearing as question marks (???) then, in most cases, problems are due to a misconfiguration in the encoding, see Jira Application internationalization and encoding troubleshooting.
Select Add.