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:

Jewelskart@greatestjewels.in via watchstore.cleanmail.in

Shoppingkart@shoppers.in via watchstore.cleanmail.in

In general,

something@somethingelse.in 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?

  • 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 Aug 24 '12 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! – Pavan Manjunath Aug 24 '12 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 Aug 24 '12 at 12:22

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/

| improve this answer | |
  • +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. – Pavan Manjunath Jun 5 '14 at 4:12
  • 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 :) – Pavan Manjunath Jun 5 '14 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 Jun 10 '14 at 19:31
  • @PavanManjunath Can you post your own answer how you did this without X-forwarded-For entry? Badly need this. Thanks. – zar Nov 14 '19 at 14:42

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

| improve this answer | |

You can filter "via" emails with this configuration:

Has the words    replyto:@domain-to-filter.com
| improve this answer | |
  • This is the easiest and immediate solution. The script is not practical in my specific case. Thank you. – R J Jul 8 at 13:00

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 = [

  //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++) {
    // 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);

          //MARK AS READ (maybe spares you an unnecessary notification)

| improve this answer | |

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) {


Hope it helps someone some day

| improve this answer | |
  • Can you elaborate please what is the label? I want to filer by the via domain. – zar Nov 14 '19 at 14:09

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.

| improve this answer | |



My suggestion is try creating filters.

| improve this answer | |
  • 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. – Andrew Lott Jan 17 '14 at 19:46
  • Nah that doesnt work – Faiz Mar 25 '14 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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