Is there a way to filter outbound email being sent?

tsutherland
Kilo Sage

I want to restrict ServiceNow from sending email to a specific email address or domain. Mail filters seem to only work on inbound email. How would I keep my instance from SENDING email to a specific address?

1 ACCEPTED SOLUTION

@tsutherland I just updated my script above realizing I forgot to include the join(",") at the end.  If you are trying my script please be sure to grab the updated version above.

 

Please mark this post or any as helpful or the correct answer if applicable so others viewing may benefit.

View solution in original post

10 REPLIES 10

Yes in this business rule you can put in script to abort if the only recipient is this specific email address otherwise it can update the recipient list using the replace():

BR Condition - recipients contains BAD-EMAIL-ADDRESS

Script:

//Abort of only recipient is bad email address
if (current.recipients == "BAD-EMAIL-ADDRESS") {
	current.setAbortAction(true);
} else {
	//Find the bad email address and remove it
	var emailRecipients = current.recipients.toString().split(",");
	var emailIndex = emailRecipients.indexOf("BAD-EMAIL-ADDRESS");
	emailRecipients.splice(emailIndex, 1);
	current.recipients = emailRecipients.join(",");
}

@tsutherland I just updated my script above realizing I forgot to include the join(",") at the end.  If you are trying my script please be sure to grab the updated version above.

 

Please mark this post or any as helpful or the correct answer if applicable so others viewing may benefit.

Thank you Michael! That worked like a charm!

Awesome glad this worked for you.  Have a great day.

I've tried to use Business Rule in domain-separated environment - does not work =( ...