Last active
November 12, 2019 10:56
-
-
Save fuglu/c1d88719621da926a20681543cdf679b to your computer and use it in GitHub Desktop.
Google Spam Filter
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 spamFilter() { | |
var threads = GmailApp.search('is:unread in:inbox'); | |
for (var i = 0; i < threads.length; i++) { | |
var thread = threads[i]; | |
if (!thread.isUnread()) { | |
continue; | |
} | |
var messages = thread.getMessages(); | |
var isSpam = false; | |
for (var b = 0; b < messages.length; b++) { | |
var message = messages[b]; | |
if (message.getBody().match(/ub.php/)) { | |
Logger.log("[SPAM]" + message.getSubject()); | |
isSpam = true; | |
break; | |
} | |
} | |
if (isSpam) { | |
thread.moveToSpam(); | |
continue; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment