dachte icon

NoMitnick

dachte | PRO | 02/17/23 08:00:58 PM UTC (Edited) | 0 ⭐ | 1228 👁️ | Never ⏰ | []
JavaScript |

1.09 KB

|

None

|

0 👍

/

0 👎

function noMitnick() {
    try {
 
    // Get the most recent 50 threads in your inbox
    var threads = GmailApp.search("in:inbox", 0, 50);
 
    // If there are threads
    if (threads.length > 0) {
 
      // For each thread
      for (var t=threads.length-1; t>=0; t--) {
 
        // Get the current thread we are iterating over
        var thread = threads[t];
        
        // Get the first message in the thread
        var message = thread.getMessages()[0];
        
        // Get the from address
        var from = message.getFrom();
            
        // See if the raw content has the header `X-PHISHTEST`
        if ((message.getHeader("X-PHISHTEST") != '') || (message.getHeader("X-MarketoID") != '') || (message.getHeader("X-Mailgun-Dkim") != '')) {
 
          // Log that the filter was created
          Logger.log("Filter phishing " + message.getDate() + "::" + message.getSubject() + " :: " + from);
          
          // Mark the thread as trash it
          thread.moveToTrash();
        }
      }
    }
  } catch (e) {
    Logger.log(e.toString());
  }
}

Comments