23

I have this annoying problem in Gmail. Spammers are by-passing the Gmail spam filters and are so clever that I am not able to create a manual filter of my own to block them. They are sending me junk mails from e-mail IDs of the form:

[email protected] via watchstore.cleanmail.in

[email protected] via watchstore.cleanmail.in

In general,

[email protected] via watchstore.cleanmail.in

Now, I cant set a filter for each and every mail as they are from different IDs. The common part is the via address which is watchstore.cleanmail.in. But when I try creating a filter with watchstore.cleanmail.in in From field, Gmail doesn't list these emails. In short, the filter is not able to detect via addresses.

Report Spam/Unsubscribe options aren't working.

How can I get rid of these annoying spammers?

4
  • 2
    Are you sure you've Report as Spam by clicking the Gmail button every mail you got? This should work for further mails. Btw, never unsubscribe to spam, it will just confirm that your address is correct.
    – JMax
    Commented Aug 24, 2012 at 9:30
  • @JMax Thanks for the reply. Though not every mail, but I used to mark many such mails as Spam. And thanks for reminding me about the unsubscribe trap! Commented Aug 24, 2012 at 9:53
  • 1
    I'm not sure if GMail has this kind of functionality. It would be a good feature for them to add so perhaps suggest it to Google. As for the Report as Spam problem, my thoughts are that it will just block spam from the apparent domain, not the domain it was sent via. Again, this may be a good feature to suggest.
    – njallam
    Commented Aug 24, 2012 at 12:22
  • This is a great solution. I used it to mark spam emails from a certain domain (with a random prefix) as read so I don't see the unread indicator. Commented Apr 20, 2021 at 12:41

7 Answers 7

9

The reason Gmail's built-in filters won't work in this situation is because they can't be applied to the "X-Forwarded-For" header. That header is where the "via" domain info is stored.

My solution was to use a Google Apps Script to check my inbox every few minutes and automatically filter out messages sent via a specific domain. It actually works really well. Since implementing the script, I haven't had to deal with this type of spam at all. You can read my full walkthrough here: http://www.geektron.com/2014/01/how-to-filter-gmail-using-email-headers-and-stop-via-spam/

4
  • 1
    +1,Excellent workaround!! But I couldn't find the "X-Forwarded-For" header. And other "headers-site names" are not in easily searchable formats. For example, "Return-Path: <campaign-value4shop-10213-2596-859268-pavan8085=gmail.com@mails.cratusservices.in>". The culprit domain "mails.cratus.." is embedded inside the header data. Can we use regular expressions to search for strings inside the headers? As of now, I am directly searching for "mail.cratus.." which is good enough for me, but may lead to false positives in future. Commented Jun 5, 2014 at 4:12
  • 1
    string.search() can do regex searching! Now my code works fine! Thanks for your help. Your answer has made me take interest in Google app scripts :) Until Google themselves come up with a feature to block via addresses, I will mark your answer as correct :) Commented Jun 5, 2014 at 10:04
  • Glad it worked for you, Pavan! I recently started experimenting with Google App Scripts as well, and there are a lot of cool useful things you can do with it!
    – Chris Z
    Commented Jun 10, 2014 at 19:31
  • @PavanManjunath Can you post your own answer how you did this without X-forwarded-For entry? Badly need this. Thanks.
    – zar
    Commented Nov 14, 2019 at 14:42
2

You can filter "via" emails with this configuration:

Has the words    replyto:@domain-to-filter.com
0
1

I have heard from a friend of mine that there is a Chrome extension that can block an email address or even the entire domain all in just one click. I haven't tried it yet but I hope this helps. Here is the link: Block Sender

0

I made a similar script, it checks for "Received From:", you can add as many domains as necessary in the domains variable.

//without http:// etc, just domain-name.com or domainname.com ....
var domains = [
  'secureserver.net',
];

  //This is not the best solution, a better solution would be to add a filter like this for example => From: #domainname.com
  //and then this app would read your GMail filters and test whether it begins with # to apply the next function if so.. but I couldn't find a way to read GMail settings from here

function filterVia() {
  // get all threads in inbox
  var threads = GmailApp.getInboxThreads();

  for (var i = 0; i < threads.length; i++) {
    Utilities.sleep(100);
    // get all messages in a given thread
    var messages = threads[i].getMessages();
    // iterate over each message
    for (var j = 0; j < messages.length; j++) {
      // log message subject
      var content = messages[j].getRawContent();

      for (var k = 0; k < domains.length; k++) {
        //make domain name as regexp
        var re = new RegExp('\\.|\\-', 'gi');
        var b = domains[k].replace(re, '\\$&');
        var regex = new RegExp("Received\: from .*" + b,'gim');
        var does_match = regex.test(content);

        if(does_match){
          //MARK AS READ (maybe spares you an unnecessary notification)
          messages[j].markRead();
          //DELETE THE MESSAGE
          messages[j].moveToTrash();          
        }

      }
    }
  }
}
0

If anyone ends up here looking for a way to filter received emails by a label and save them to the label's folder instead of marking them as spam and trashing them, here's a script doing just that (Edited the one provided by @ChrisZ).

function filterByVia() {
  var threads = GmailApp.getInboxThreads(0, 5);
  var label = GmailApp.getUserLabelByName("yourlabel");
  for (var i = 0; i < threads.length; i++) {
    var messages=threads[i].getMessages();
    for (var j = 0; j < messages.length; j++) {
      var message=messages[j];
      var body=message.getRawContent();
      if (body.indexOf("the domain after via") > -1) {
        label.addToThread(threads[i]);
      }
      Utilities.sleep(1000);
    }

   }
 }

Hope it helps someone some day

0
0

It has taken some work, but the answer turns out to be rather simple:

  • In each email there is a header that carries the website of the "via" sender.
  • In the email, upper right, click the three vertical dots, and choose "show original" and it should pop up in a new tab. It's the coded version of the email with headers.
  • Scroll down and search for the line that has: "dkim=pass header.i=@(website.com)"
  • Copy this bit
  • Then in the actual email (original window), click the three vertical dots again, and choose "filter messages like this"
  • In the pop-up window, go to line "has the words" and there paste what you just copied.
  • Also, remove anything from the "from" line.
  • Click "create filter" at the bottom of the window.
  • Check the box "delete it" and "create filter" again.

Ta-dah! That does it.

-3

https://support.google.com/mail/answer/6579?hl=en

http://mashable.com/2012/06/22/gmail-filters/

My suggestion is try creating filters.

2
  • 1
    Can you give a bit more detail on what needs to be done? Link-only answers aren't as helpful as giving a recap here of the required action. Also, if the links go down, there's still something helpful for future visitors. Commented Jan 17, 2014 at 19:46
  • Nah that doesnt work
    – Faiz
    Commented Mar 25, 2014 at 17:20

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.