How to configure sending email for all events related to issues to a non Jira user email in Jira DC
Asked by Satchidanand_CS_ext:

Hi,

there is a requirement to send an email for issue created updated and all the events related to it to multiple non jira user group emails for a particular project. can someone try to help as quickly as possible. Our instance is Jira Data center. I found few pages to see if we can use listener but as I'm not familiar with the script could not apply it.

Regards,

CS Satchidanand


Answers:
author: Evgenii
body: Hi, [@Satchidanand_CS_ext](/t5/user/viewprofilepage/user-id/5238609)

Of course, you can use script with listener, but if you don't have experience in scripting, maybe it's better to use Jira Automation?

Jira DC has Automation by default.

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/265256iBB3C56C279F2FA89/image-size/large?v=v2&px=999 "image.png")

comments: author: Satchidanand_CS_ext
body: Hi [@Evgenii](/t5/user/viewprofilepage/user-id/3993514) appreciate your help I have tried this automation before as well it says successfully sent email but there is nothing received in the mail box  

![automation.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/265274iD1AE65926E5F0407/image-size/large?v=v2&px=999 "automation.PNG")


author: Evgenii
body: Well, if you want, I can give you script for sending emails, but Automation is a good tool too and it's worth to fix it.

I'd check email queues in Jira, to see, if letter appear there, when rule triggers, and of course it's a good idea to check spam folder in mailbox. I often use this functionality, to send letters to gmail mailbox and letters deliver successfully.


author: Satchidanand_CS_ext
body: email queues im seeing it empty none in email queue or error queue. any setting im missing to check for configuring


author: Evgenii
body: The easiest from UI is:  
Open email queue in one window, and in another window - run action, to trigger sending email. After that refresh window with email queue. There must appear new email, which is waiting to be send.


author: Evgenii
body: As I promised, example code to send emails. It can be run from console or listener:

```
/*
 * Created 2023.
 * @author Evgeniy Isaenkov
 * @github https://github.com/Udjin79/SRUtils
 */

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.mail.Email
import com.atlassian.mail.queue.SingleMailQueueItem

String emailAddr = "your_mailbox@gmail.com"
String subject = "TEST letter"
String body = "TEST email body"

Email email = new Email(emailAddr)
email.setSubject(subject)
email.setBody(body)
email.setMimeType('text/html; charset=utf-8')
SingleMailQueueItem smqi = new SingleMailQueueItem(email)
ComponentAccessor.getMailQueue().addItem(smqi)
```


author: Satchidanand_CS_ext
body: I see this happening but still no email incoming to the mail box


author: Evgenii
body: If your company use your own mail server, ask your mail administrator to check mail logs, to see, what happens with sent emails.


author: Satchidanand_CS_ext
body: I am all set but what should I mention in order to get the details for example  

Subject: Issue Key was Just created or updated  

Content:  

If it should be mentioned event-wise  

summary of the ticket/comments updated/issue fields. how to place smart values so that it can take it from the ticket


author: Evgenii
body: Clarify please, you're talking about automation rule or script?


author: Satchidanand_CS_ext
body: For the Automation rule


author: Evgenii
body: Ok, understood. You can use next Smart Values for getting summary or changes, for example:

    {{issue.description}} - issue description{{issue.summary}} - issue summary
    {{issue.key}} - issue key

    // Summary changes
    {{#changelog.summary}}  {{toString}}{{/}}

    // Previous status name{{#changelog.status}}{{fromString}}{{/}}

If you want to show event type, you can use:  

    {{eventType}}

Also, event type Smart Value can be used for managing rule conditions.

More information can be found here:

<https://confluence.atlassian.com/automation/smart-values-in-jira-automation-993924627.html>