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

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

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

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.

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

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.

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?

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?

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?

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

 

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?

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

@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.

@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)

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted yesterday in Confluence

Calling all marketing teams who use Confluence - we want to hear from you!

Hi Community! me again 🙂 If you’re a marketing team using Confluence, we want to hear your story! How did you start using Confluence? What are your use cases? What have been some of the benefits?...

46 views 1 2
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you