Automatically delete fake phishing emails from IT
This file contains 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: abuse-siq@infosecinstitute.com | |
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