Last active
November 9, 2023 19:04
-
-
Save lewayotte/a33304f5f55a6dca2ce40b85aa1a6dae to your computer and use it in GitHub Desktop.
Automatically delete fake phishing emails from IT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function filter_emails() { | |
/// 1day is the smallest increment | |
var threads = GmailApp.search("newer_than:1d in:inbox"); | |
for (var i = 0; i < threads.length; i++) { | |
// get all messages in a given thread | |
var messages = threads[i].getMessages(); | |
for (var j = 0; j < messages.length; j++) { | |
var body = messages[j].getRawContent(); | |
// Possible headers to filter | |
// X-PHISH: This is a security awareness phishing simulation test from InfoSec Institute that has been authorized by the recipient organization | |
// X-Report-Abuse-To: [email protected] | |
if (body.indexOf("X-PHISH-CRID") > -1) { | |
message[j].markRead(); | |
message[j].moveToTrash(); | |
} | |
} | |
} | |
} | |
/* | |
* Go to script.google.com | |
* Add new project | |
* Add the above code | |
* Click save icon | |
* Go to Triggers | |
* Add new trigger | |
* Everything is gravy | |
* / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment