The CreatorCon Call for Content is officially open! Get started here.

How to selectively send mail from test env?

thomaskennedy
Tera Guru

The mail-send process is switched off in our test environment. So apps running in test can create email, but it isn't sent. We're being directed to switch that on to make testing more realistic, in support of the following cases:

(a) so testers can confirm the format and content of the email is correct

(b) for tests whose scope includes the recipient following a link to do an approval etc (that is, cases where impersonation won't help)

My first thought was to look for an interceptor pattern, for example to programmatically replace the sendto value for any email created with some testing mailbox, and I understand there was one but it is now deprecated. This would be clumsy, but it should work, if there is a replacement for the interceptor.

All this suggests a solution that:

(1) lets us selectively allow some emails to be sent, for example if the sendto contains a person or group that is listed in a certain system property ("UAT Passthrough Recipients" property contains "Bill Smith") AND the subject matches a certain pattern declared in a property (Subject contains a value found in property "UAT Passthrough Subjects"), while all others don't get sent.

(2) is invisible to the various applications

Can someone make suggestions?

4 REPLIES 4

Chuck Tomasi
Tera Patron

A common solution that I have seen is people using the "catch all" address to go to a distribution list or shared mailbox.



find_real_file.png



Then let your testers use that. It keeps it separate from their personal accounts and you can shut them off at any time.


Sorry, I should have noted. Get there from System Properties> Email Properties.



Email Properties - ServiceNow Wiki


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

HI Thomas,



You can also preview email notification from email logs record. Please refer section 3.2 for more info.


Viewing System Logs - ServiceNow Wiki


Lokesh Kankipat
Tera Contributor

One way to do this, I'm not going to endorse this solution, I'm just suggesting.



Have all the user records' email id set to a specific unused email id in your company(or any dummy email account).



Allow the emails to go forward in the email properties by removing the data in "Send all email to this test email address (non-production testing)".



Select the users who are testing and update their records with the correct email id's.



This will ensure that the people who are testing in Non-Prod Environments would be able to realistically test the email scenarios.



Thank you,



Lokesh Kankipati



PS : Some companies might have issues with sending emails to external domains like gmail or yahoo.





Edit :   You might want to follow along with the testing process to "switch off" the emails being sent after the testing is done. Its always annoying to get irrelevant emails.