Invalid 'from' address - Workround script

steveturley
Tera Guru

Hi. We have the issue described in the KB article below whereby an email (from a Voicemail number) is triggering the 'invalid address' filter.

 

It appears that I need to create the business rule script detailed in this article. When email headers contain an invalid 'from' address the email moves to state ignored and in the Jun...

 

However, being as script novice, I'm not sure where the conditions are in the script that would limit this to work with the particular email that we are receiving. Our emails are coming from a particular recipient and have 'voice mail' the in subject

 

Could anyone advise what values in the script I'd need to change? Thanks!

5 REPLIES 5

Sohail Khilji
Kilo Patron
Kilo Patron

unable to access the link, 

you need to provide the script

screeshort of KB 

 

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

steveturley
Tera Guru

Screenshot of KB below

 

Screenshot 2024-04-30 115853.png

 

Script below

 

(function executeRule(current, previous /*null when async*/) {

var checkExistingEvts = GlideRecord("sysevent");
checkExistingEvts.addEncodedQuery("stateNOT INprocessed,error,transferred");
checkExistingEvts.addQuery('name', 'email.read');
checkExistingEvts.addQuery('parm1', current.sys_id);
checkExistingEvts.query()
if(checkExistingEvts.getRowCount() == 0)
{
    // no existing re-tried email.read events for this email so safe to proceed (safety check to prevent infinite loop of email.read sysevent creation)
    var evt = new GlideRecord('sysevent');
    evt.initialize();
    var guest = new GlideRecord('sys_user');
    guest.addActiveQuery();
    guest.addQuery('user_name', 'guest');
    guest.query();

    if (guest.next()) {     evt.user_id = guest.sys_id;     evt.user_name = guest.user_name;     }     evt.process_on = gs.nowDateTime();     evt.name = "email.read";     evt.parm1 = current.sys_id;     evt.insert();     gs.addInfoMessage(gs.getMessage('Event created to reprocess email "{0}"',Packages.org.apache.commons.lang.StringEscapeUtils.escapeXml(current.subject)));
    if (current.type == 'received-ignored') {     current.type = "received";     } } })(current, previous);

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @steveturley ,

 

Thanks for sharing the screenshort and BR script. 

 

As i can see the BR script is trying to create an event on the system, when invalid email ID emails are received this business rule triggers an event and that event in turn reprocesses the email received.

 

I understand, in your case your trying to allow reprocess those email if the subject contains 'voice mail'.

 

so the recommedation here is just to create this business rule without any conditions as suggested in KB, this will allow to reprocess all the invalid email id emails. 

 

if in case you wanted to allow reprocessing only for 'voice mail' subjected email then the below BR script will helps (i have adjusted to code to check for subject containing voice mail)

 

(function executeRule(current, previous /*null when async*/) {

var checkExistingEvts = GlideRecord("sysevent");
checkExistingEvts.addEncodedQuery("stateNOT INprocessed,error,transferred");
checkExistingEvts.addQuery('name', 'email.read');
checkExistingEvts.addQuery('parm1', current.sys_id);
checkExistingEvts.query()
if(checkExistingEvts.getRowCount() == 0 && current.subject.indexOf('voice mail') != -1) // added subject check here
{
    // no existing re-tried email.read events for this email so safe to proceed (safety check to prevent infinite loop of email.read sysevent creation)
    var evt = new GlideRecord('sysevent');
    evt.initialize();
    var guest = new GlideRecord('sys_user');
    guest.addActiveQuery();
    guest.addQuery('user_name', 'guest');
    guest.query();


    if (guest.next()) {
    evt.user_id = guest.sys_id;
    evt.user_name = guest.user_name;
    }
    evt.process_on = gs.nowDateTime();
    evt.name = "email.read";
    evt.parm1 = current.sys_id;
    evt.insert();
    gs.addInfoMessage(gs.getMessage('Event created to reprocess email "{0}"',Packages.org.apache.commons.lang.StringEscapeUtils.escapeXml(current.subject)));


    if (current.type == 'received-ignored') {
    current.type = "received";
    }
}

})(current, previous);

 

I hope this helps...

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi @Sohail Khilji 

 

Thanks so much for the script. I've look at the trigger emails and the subjects can read 'Voice Mail (16 seconds)' or 'Voice Mail (12 seconds) for example. Will that cause a problem with the script?

 

If so, they do all seem to come from the same Recipient address - would that be better to use?

 

Thanks

 

Steve