Notifications

74 views

Overview

An "infinite email" loop occurs when an update to a record triggers a notification which sends an email to an external recipient.

The receipt of that email on the external system can trigger an automatically generated reply, which is then sent back to ServiceNow. 

When we process that email, it may be added to the comments or worknotes of the record, thus triggering another update which sends another email to the external recipient, therefore causing an infinite loop.

 

Solution 1

Ignoring emails with the Auto-Submitted:auto-generated header

The first solution is to simply ignore emails that are generated with the "Auto-Submitted:auto-generated" header. 

You can modify email properties by navigating to either the System Mailboxes > Administration > Email Properties module or the System Properties > Email Properties module, or by navigating to the /sys_properties_list.do list and searching for the glide.pop3.ignore_headers system property. 

This system property is a string and the default value is:

Ignore mail with these headers (comma separated name:value pairs)
X-ServiceNow-Spam-Flag:YES,X-ServiceNow-Virus:INFECTED,Auto-Submitted:auto-replied,X-ServiceNow-Generated:true,X-FC-MachineGenerated:true,Content-Type:multipart/report; report-type=delivery-status;

 

Please note that this string already shows "Auto-Submitted:auto-replied", but not "Auto-Submitted:auto-generated".  We can add this to the string, though:

Ignore mail with these headers (comma separated name:value pairs)
X-ServiceNow-Spam-Flag:YES,X-ServiceNow-Virus:INFECTED,Auto-Submitted:auto-replied,Auto-Submitted:auto-generated,X-ServiceNow-Generated:true,X-FC-MachineGenerated:true,Content-Type:multipart/report; report-type=delivery-status;

 

This will ignore the auto-generated emails and avoid the infinite loop.

 

Solution 2

Disabling Workflow when updating the comments of the target record

Another solution is, when you have a script (such as an "Inbound Email Action" [sysevent_in_email_action] script) that is processing the inbound email, don't trigger business rules / workflows when you update the target record. 

For example:

 

(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
if (current.getTableName() == "incident") {
current.comments = "Reply From: " + email.origemail + "\n\n" + email.body_text;
current.setWorkflow(false);
current.update();
}
})(current, event, email, logger, classifier);


This will update the target record with the comments, but it will avoid triggering the business rules that again trigger the notification.

 

Solution 3

Modify the "Ignore header" Email Filter

Similar to setting the glide.pop3.ignore_headers system property, we can create or modify an email filter via the System Mailboxes > Administration > Filters module.

There is an out-of-the-box filter named "Ignore header" that ignores emails that contain these headers:

  • Auto-Submitted:auto-replied
  • X-ServiceNow-Generated:true
  • X-FC-MachineGenerated:true
  • Content-Type:multipart/report; report-type=delivery-status;

You can click on the OR button and add another condition that ignores the emails with headers that contain "Auto-Submitted:auto-generated":

 

Additional Information

Inbound mail configuration

Email Filters

Activate Email Filters

Create an email filter

 

Article Information

Last Updated:2019-06-17 19:02:59
Published:2019-06-18