OnToOrCC

From Request Tracker Wiki
Revision as of 16:15, 6 April 2016 by Admin (talk | contribs) (2 revisions imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Purpose: We have multiple mailboxes to accept requests to a single RT system. There are certain scripts that I want to execute for some mailboxes but not others. For example we have a paging scrip for off hours but don't want to page for a certain mailbox.

This condition scrip searches the headers for a particular email account in the TO or CC line of the email. If it finds a match it exits out and does not execute. Of course you can flip the result bit so it does do something.

Author: macnlos AT comcast DOT net - I'm on the RT Users List

Condition: User Defined

Custom Condition:

# Parse out if the email was sent to Clarity and exclude
 my $ContentObj = $self->TransactionObj->Attachments->First();
 my $Headers = $ContentObj->{values}{headers};
 if ($Headers =~ /^To: .*ACCOUNT.*/im) {
    return 0;
 }
 if ($Headers =~ /^CC: .*ACCOUNT.*/im) {
    return 0;
 }
 
 return 1;
 
 
 

Code Explanation: This condition grabs the first attachment and gets the header block. It then searches through the headers looking for a line that starts with "To:" or "CC:" and then for a particular ACCOUNT.

The /im on the regex makes it case-insensitive and treats each line in the multi-line block as and individual line. If you don't have the /m then the ^ anchor will only go on the very first line.