"Send a custom email" post function - mail not sent

Arianna Fabbri November 29, 2016

Hi,

I've added some post functions "Send a custom email" that are apparently working if I try to execute a preview but are not really working. Users tell me that they are not receiving emails.

I've added some lines of log and the log is correctly printed but no mails are sent.

How can I further debug the reasons of this problem?

 

thank you

2 answers

0 votes
Jonny Carter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 30, 2016

So, JIRA keeps a separate log for the mail handler. Look for atlassian-jira-outgoing-mail.log in your JIRA home. If JIRA's having trouble sending out the messages for some reason, the errors will likely be in there.

Your log statements may not show up in your logs unless you use log.warn or log.error. Alternately, you can crank up the logging level for the ScriptRunner packages by running the script below in the Script Console.

import org.apache.log4j.Level
import org.apache.log4j.Logger

Logger.getLogger("com.onresolve.jira.groovy").setLevel(Level.DEBUG)

Those logs will show up in the normal atlassian-jira.log file.

Arianna Fabbri December 1, 2016

Hi @Jonny Carter [Adaptavist],

I've enabled to DEBUG log directly in the post function "Send Custom Email" in order to print:

  1. if the step is executed
  2. if the condition is true
  3. how are the recipients of the email

I've also enabled the outgoing-email-log

The problem is that:

  • from the log I see that the condition is true and the recipients are correctly selected
  • from the workflow step I get a green check exactly on the timestamp of the logged execution
  • in the outgoing-mail-log there are no entries related to my email
  • the recipients are not receiving any notification (until some weeks ago the same workflow with the same notifications was working sad )

Should I have to update to the last version of script runner? We currently have version 4.1.3.11 and I see that there is version 4.1.3.22 available for download.

Thank you again for your support

Jonny Carter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 6, 2016

There was a small change in 4.1.3.22 that made it a bit easier to pick users for scripts like Send Custom Email. I'd be surprised if that resolved your issue–if anything, it sounds like there may be something amiss with your mail server configuration–but it's definitely worth a shot.

Jonny Carter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 6, 2016

Also, I'd be curious what else might have changed in your JIRA instance in the past few weeks. If your notification script didn't change, is there anything else that could have caused the issue?

Arianna Fabbri December 7, 2016

Unfortunately nothing changed and, in addition to this, all other standard notifications from JIRA still work.

Any idea about how to log this behaviour?

Should I have to upgrade Script Runner version?

Jonny Carter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 7, 2016

Do you see any warnings in your logs like with the text "Error sending email" or "No mail server or sending disabled."? Those warnings would happen if sending were disabled for some reason, or there were some trouble adding an item to the mail queue. You might also check your mail queue. Could be the messages are getting stuck there for some reason?

Arianna Fabbri December 7, 2016

No warnings like that ones in atlassian-jira.log file and no mails in the queue.

What is strange is also that some emails are sent (related to specific workflow transitions) and some others, on transitions of the same workflow, are no longer sent. sad

 

Jonny Carter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 7, 2016

That sounds suspiciously like you have a condition on the post function that's causing them not to send. It would also account for the successful execution history, even though no emails go out. What condition clause are you using on the workflow steps that are failing, compared to what you're using where you're successfully getting email?

Arianna Fabbri December 7, 2016

I've added logs in the conditions scripts with the result of the evaluated conditions and the result is true.

An example is:

2016-12-02 15:24:41,451 Thread-2064 DEBUG XXXX [...] [Workflow Outgoing Emails Log] Transition 'Approve'(201): Issue => XX-265
2016-12-02 15:24:41,452 Thread-2064 DEBUG XXXX [...] [Workflow Outgoing Emails Log] Transition 'Approve'(201): user1.toString() => x.y
2016-12-02 15:24:41,452 Thread-2064 DEBUG XXXX [...] [Workflow Outgoing Emails Log] Transition 'Approve'(201): user2.toString() => z.w
2016-12-02 15:24:41,453 Thread-2064 DEBUG XXXX [...] [Workflow Outgoing Emails Log] Transition 'Approve'(201): Evaluated condition => true
2016-12-02 15:24:41,453 Thread-2064 DEBUG XXXX [...] [Workflow Outgoing Emails Log] Transition 'Approve'(201): To => z.w:10000
2016-12-02 15:24:41,453 Thread-2064 DEBUG XXXX [...] [Workflow Outgoing Emails Log] Transition 'Approve'(201): CC => email1@XX.com
Arianna Fabbri December 7, 2016

@Jonny Carter [Adaptavist]: if it can be useful, it seems that the notifications that are no longer working are those for which both "" and "" are filled in in the post function configuration.

Jonny Carter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2016

@Arianna Fabbri - If you remove one of those CC fields (either the CC addresses or the CC issue fields), do the notifications go out? If not, that's probably a red herring; those fields should work together normally.

I'm assuming the above log sample from a mail that successfully went out, right? Not a failed one?

Something that might help is to crank up the debug logging for ScriptRunner itself and see if you can find some messages from the SendCustomEmail function itself.

import org.apache.log4j.Level
import org.apache.log4j.Logger

Logger.getLogger("com.onresolve.jira.groovy").setLevel(Level.DEBUG)
0 votes
Arianna Fabbri November 29, 2016

The "Send custom email" post function has to be added before or after the issue reindex? Is this important or not?

Suggest an answer

Log in or Sign up to answer