I was trawling through my spam folder (which I rarely do, because Gmail rarely has false positives) and I noticed something interesting:

sample list of spam messages

Something like over half of the messages have at least one animated emoji in the subject.

None of my friends would use that crap. No valid company that I'd do business with would ever do that either.

How can I create a filter to, perhaps, auto-delete messages with animated emoji in the subject?

Using jamesmstone's clue below, I tried a search with subject:=?UTF-8? and subject:"=?UTF-8?" and several other permutations, but none worked.

Here's a sample set of headers from one of these steaming piles:

Delivered-To: [redacted]@gmail.com
Received: by with SMTP id c191csp1104992ioc;
        Sun, 24 Jan 2016 19:07:16 -0800 (PST)
X-Received: by with SMTP id m5mr15068933iom.15.1453691236564;
        Sun, 24 Jan 2016 19:07:16 -0800 (PST)
Return-Path: <[email protected]>
Received: from mythirdxyz.xyz ([2a04:5b00:a2d0:3d74:37fd:ee71:efe6:6e11])
        by mx.google.com with ESMTP id o10si8722554igw.41.2016.
        for <[redacted]@gmail.com>;
        Sun, 24 Jan 2016 19:07:16 -0800 (PST)
Received-SPF: pass (google.com: domain of [email protected] designates 2a04:5b00:a2d0:3d74:37fd:ee71:efe6:6e11 as permitted sender) client-ip=2a04:5b00:a2d0:3d74:37fd:ee71:efe6:6e11;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of [email protected] designates 2a04:5b00:a2d0:3d74:37fd:ee71:efe6:6e11 as permitted sender) [email protected];
       dkim=pass [email protected];
       dmarc=pass (p=REJECT dis=NONE) header.from=mythirdxyz.xyz
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mythirdxyz.xyz; 
 [email protected]; q=dns/txt; s=default; t=1453691229; 
 bh=GuM9JCP4yh7WfVbRBortR7UAr6DAtlgy0oTCna0iWQk=; h=MIME-Version : 
 Content-Type : Content-Transfer-Encoding : To : From : Subject : Date : 
 Message-ID : From : Subject : Date; 
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: base64
To: [redacted]@gmail.com
From: "APPROVAL DEPARTMENT" <[email protected]>
Subject: =?utf-8?q?=F3=BE=93=A0_Personal_loan_as_soon_as_tomorrow_=F3=BE=93=A0?=
Date: Sun, 24 Jan 2016 19:07:09 -0800
Message-ID: <[email protected]>
  • 3
    I wonder if they are goomoji... Commented Jan 25, 2016 at 12:06
  • @jamesmstone: I expect that they are.
    – ale
    Commented Jan 25, 2016 at 18:24
  • animated? i have the same issue, but i've never seen any of the emoji move...
    – Michael
    Commented Nov 22, 2021 at 14:30

3 Answers 3


Short answer

Instead of using Gmail Filters that depends on the Gmail search feature to search for the encoded emojis in the orignal messages, create a script using the GmailMessage::getRawContent() method of Google Apps Script to process the messages.

Related questions

The following are links to answers to similar questions in this site including scripts using the referred method.

  • 3
    It's worth mentioning that a script cannot completely delete a message - the most it can do is move it to trash or spam folder. And if such messages already go to spam, there is little benefit from the script.
    – user79865
    Commented Jan 29, 2016 at 14:23
  • @Minestrone: Actually, it's possible to delete completely a message using a script. It should use the Gmail API . See developers.google.com/gmail/api/v1/reference/users/messages/…. To use the Gmail API in Google Apps Script, see developers.google.com/apps-script/guides/services/advanced. Commented Jan 29, 2016 at 14:58
  • 2
    I'm not so much interested in actually deleting the message as I am in finding a way to filter them. I might simply want to put a label to them.
    – ale
    Commented Jan 29, 2016 at 20:28
  • @AlE. I assumed that, so I didn't mentioned the use of the GMAIL API in the body of the answer. By the other hand, fortunately I didn't have received email with emojis in the subject. Commented Jan 29, 2016 at 20:38

I have created a Google Apps Script for such purposes.

It is on Github: https://github.com/spamzero/spamzero

It lets you create all sorts of advanced rules that you can match against your spam message folder, so messages that are definitely spam will be cleaned up automatically.

  • 1
    Your answer will be better if you include a brief description of the script highlighting how it will help to handle messages with animated emojis in the subject. Commented Mar 14, 2016 at 1:13
  • 4
    I agree with @Rubén, the more information the better. Since it allows readers to vet answers' viability without jumping through too many hoops. Commented Mar 14, 2016 at 2:02
  • Thanks for this script! Sometimes the most helpful solutions are the ones that reduce daily annoyances like animated spam. I would suggest adding to the Github README this link for Google Apps Script Quickstart so users who don't have any experience with using scripts know how to enable the Gmail API and view logs.
    – dan
    Commented Jun 6, 2018 at 4:28
  • Is there any reason this can't be run on new mail messages as they arrive, rather than blindly running it every hour on the entire mailbox?
    – Michael
    Commented Dec 7, 2021 at 23:45

This is not quite what you are asking for (filtering out the emojis themselves rather than the messages with emojis) but you may find some of the content useful for building a better message filter.

There is now an open-source Greasemonkey/Tampermonkey/Violentmonkey userscript to get rid of those irritating visual cockroaches (just the characters, not the messages themselves):

Gmail Subject Line Emoji Roach Motel

Looking at the source to that script, you will see that there are two general types of emoji cockroaches that you will find in emails from abusive marketers (nowadays including eBay and Amazon, sadly):

  • HTML-image-based cockroaches (including the horrible animated ones) aka goomoji

  • Unicode cockroaches: There are still many many emoji (and other Unicode sequences generating pictures) that spammers and other erstwhile marketers are starting to use in email subject lines and that gmail does not convert to HTML images. In some browsers these show up bold and colored, which is almost as bad as animation. Browsers could also choose to animate these, but I don't know if any do. These Unicode sequences get displayed by the browser as Unicode text, so the exact appearance (color or not, animated or not, ...) depends on what text rendering system the browser is using. The appearance of a given Unicode emoji also depends on any Unicode variation selectors and emoji modifiers that appear near it in the Unicode code point sequence. Unlike the image-based emoji spam, these sequences can be copied-and-pasted out of the browser and into other apps as Unicode text.

For the latter type, the userscript includes a regular expression designed to capture the Unicode sequences likely to be abused by marketers. The regex looks like this in ES6 Javascript (the userscript translates this to widely-supported pre-ES6 regex using the amazing ES6 Regex Transpiler):

var re = /(\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F|[\u{2100}-\u{2BFF}\u{E000}-\u{F8FF}\u{1D000}-\u{1F5FF}\u{1F650}-\u{1FA6F}\u{F0000}-\u{FFFFF}\u{100000}-\u{10FFFF}])\s*/gu

// which includes the Unicode Emoji pattern from
//   https://github.com/tc39/proposal-regexp-unicode-property-escapes
// plus also these blocks frequently used for spammy emojis
// (see https://en.wikipedia.org/wiki/Unicode_block ):
//   U+2100..U+2BFF     Arrows, Dingbats, Box Drawing, ...
//   U+E000..U+F8FF     Private Use Area (gmail generates them for some emoji)
//   U+1D000..U+1F5FF   Musical Symbols, Playing Cards (sigh), Pictographs, ...
//   U+1F650..U+1FA6F   Ornamental Dingbats, Transport and Map symbols, ...
//   U+F0000..U+FFFFF   Supplementary Private Use Area-A
//   U+100000..U+10FFFF Supplementary Private Use Area-B
// plus any space AFTER the discovered emoji spam

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.