Last active
September 27, 2021 15:49
-
-
Save jeffellis/29b1c2b3a59ac590e309d2407944b85b to your computer and use it in GitHub Desktop.
Gmail script to move phishing emails to trash
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 processInbox() { | |
// process all recent threads in the Inbox (see comment to this answer) | |
var threads = GmailApp.search("newer_than:1d"); | |
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 message = messages[j]; | |
processMessage(message); | |
} | |
} | |
} | |
function processMessage(message) { | |
var body = message.getRawContent(); | |
if (body.indexOf("X-Blackfin-Assessment") > -1) { | |
message.moveToTrash(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment