---
title: "Send Custom Email Notifications in Jira Cloud with Power Scripts"
canonical: "https://support.appfire.com/space/SUPPORT/3493789745/Send%20Custom%20Email%20Notifications%20in%20Jira%20Cloud%20with%20Power%20Scripts"
format: markdown
---
This guide explains, in plain language, how to send custom email notifications in Jira Cloud when a specific issue condition is met. It is intended for admins and teams who want an easy-to-follow alternative to the older `raiseEvent` approach used in Jira Server or Data Center.

## Overview

In Jira Server and Data Center, some teams used the `raiseEvent` function to trigger custom notifications. That function is not available in the same way in Jira Cloud. As an alternative, you can use Power Scripts to:

1. Check whether an issue matches your notification rules.
2. Look up the members of a Jira group.
3. Send an email to those group members.

## What You Need Before You Start

1. **Power Scripts for Jira Cloud** installed and available to your Jira administrators.
2. **Outgoing email configured** in Power Scripts so the app can send emails.
3. **An Atlassian API token** for an account that has permission to read Jira group members.
4. **Your Jira site URL**, such as `https://your-company.atlassian.net`.
5. **The IDs of the Jira custom fields** used by your rule, such as the field that stores the phase or the group to notify.

## Notification Scenario

A notification rule can be configured to send an email when the issue matches the conditions you define, such as:

- A selected field contains a value that should trigger a notification.
- The issue belongs to a project or area where the rule should apply.
- A Jira group has been selected as the notification audience.

The script then finds the users in the selected group and emails them with the relevant issue details.

## Script Template

```sil
// Replace customfield_XXXXX with the custom field ID used to check your notification condition
string[] conditionValues = #{customfield_XXXXX};

// Replace CONDITION_VALUE with the value that should trigger the email
// Replace EXCLUDED_PROJECT_KEY with any project key where the rule should not apply, if needed
if (arrayFind(conditionValues, "CONDITION_VALUE") >= 0 && project != "EXCLUDED_PROJECT_KEY") {

    // Replace customfield_YYYYY with the custom field ID for your group picker field
    string notificationGroup = #{customfield_YYYYY};

    if (notificationGroup != "") {
        // Create the authorization header for the Jira REST API
        // Replace YOUR_BASE64_TOKEN_HERE with your encoded email:API-token value
        HttpRequest request;
        HttpHeader header = httpCreateHeader("Authorization", "Basic YOUR_BASE64_TOKEN_HERE");
        request.headers += header;

        // Replace your-company with your Jira Cloud site name
        string url = "https://your-company.atlassian.net/rest/api/3/group/member?groupname=" + notificationGroup;
        string response = httpGet(url, request);

        // Collect email addresses from the API response
        string[] parts = split(response, "\"emailAddress\":\"");
        string[] emails;
        int i = 1;
        while (i < size(parts)) {
            int emailEnd = indexOf(parts[i], "\"");
            string email = substring(parts[i], 0, emailEnd);
            emails += email;
            i = i + 1;
        }

        // Send the email if at least one address was found
        if (size(emails) > 0) {
            string emailSubject = "[" + project + "] " + key + " - " + summary;
            string emailBody = "Notification from Jira\n\n"
                + "Project: " + project + "\n"
                + "Issue: " + key + "\n"
                + "Summary: " + summary + "\n"
                + "Status: " + status + "\n"
                + "Reporter: " + reporter + "\n"
                + "Assignee: " + assignee + "\n\n"
                + "View issue: https://your-company.atlassian.net/browse/" + key;

            sendEmail(emails, emailSubject, emailBody);
        }
    }
}
```

## How to Set It Up

1. **Configure outgoing email.** In Jira, go to **Jira Settings** > **Apps** > **Manage apps** > **Power Scripts** > **Configurations** > **Integrations** > **Outgoing Mail**. Add and test your mail settings.
2. **Create an API token.** Generate a token from your Atlassian account security settings, then encode your email address and API token in this format: `email@example.com:API_TOKEN`.
3. **Find your custom field IDs.** In Jira, open **Jira Settings** > **Issues** > **Custom Fields**. Edit the field and check the field ID in the URL.
4. **Update the script placeholders.** Replace the custom field IDs, Jira site URL, project key, phase value, and authorization token with values that match your environment.
5. **Save the script.** Add the script in SIL Manager.
6. **Create a listener.** In Power Scripts, create a listener for the event you want, such as **Issue Created** or **Issue Updated**, and select the script.
7. **Test with a sample issue.** Use a test issue and test group first to confirm that the right people receive the email.