I know there are some subscription tools I could use to filter these out, and there are some friction-creating tools I can use to keep them out of my inbox (like the ones that force senders to prove they're human 1x before their emails are delivered).
But I figured there had to be a better solution that is (1) free and (2) not a hassle to people I correspond with.
After a chat with Gemini, I ended up creating a Google script that works very well for my purposes.
It simply takes any email that's in my Inbox and if it's from a sender that I've never emailed before, it moves it to a purgatory folder that I can review later. The script runs once a minute.
Pros: this is simple and deterministic. Gemini tried to get me to build a script that used AI to process emails, but I didn't want to send all my emails to an LLM, and the efficacy could vary over time, as the cat-and-mouse game of AI-spam versus AI-detection plays out.
Cons: it does not prevent emails from landing in your Inbox in the first place, possibly triggering a notification. For me, this is OK because I use the gmail app on my phone and have it set to only notify for Important emails. Gmail is pretty good at recognizing unimportant emails, so when the emails that will be filtered first land, they most likely won't trigger a notification
It's possible this will be over-inclusive, and I will be annoyed not to have seen a time-sensitive email about a conference I'm at, or some such thing. Time will tell, but so far I'm really glad to have these useless and frequent emails swept out of my Inbox.
If you have found any other free/innovative ways to get rid of AI-generated spam, please share! I'm sure there are better ideas than what I've come up with (and which Gemini wrote for me).
I've included the Google script I use below. Note that you have to turn on the option (in Settings / General) to automatically add email recipients to your Other Contacts.
Create a new script at https://script.google.com using this for the body:
function filterUnknownSenders() {
// Label to hold unknown emails for easy reviewing
const LABEL_NAME = "Review/Unknown";
let unknownLabel = GmailApp.getUserLabelByName(LABEL_NAME);
if (!unknownLabel) {
unknownLabel = GmailApp.createLabel(LABEL_NAME);
}
// Find unread messages currently sitting in your primary inbox
const threads = GmailApp.search("is:unread in:inbox", 0, 15); for (const thread of threads) {
const message = thread.getMessages()[0];
const sender = message.getFrom();
const senderEmail = extractEmail(sender);
// Check if you have ever sent an email to this address
const sentHistory = GmailApp.search(`to:${senderEmail}`, 0, 1);
// If you have NEVER emailed this person, archive and label the message
if (sentHistory.length === 0) {
thread.moveToArchive();
thread.addLabel(unknownLabel);
GmailApp.markThreadUnimportant(thread); // Prevents "Important" notifications
Logger.log(`Archived unknown sender: ${senderEmail}`);
}
}
}// Helper to pull clean email address from "Name <email@domain.com>" sender strings function extractEmail(senderString) { const match = senderString.match(/<([^>]+)>/); return match ? match[1] : senderString; }
0 comments