Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

Is there a way to search/filter gmail emails by the absolute domain without subdomains? If just do a search/filter on from:@google.com it includes all subdomains like plus.google.com, txt.voice.google.com, etc.

I know I can manually exclude all of those with -{from:plus.google.com from:txt.voice.google.com}, but the list of subdomains is quite long (and I don't really know the full list).

share|improve this question

migrated from superuser.com Feb 23 '13 at 22:39

This question came from our site for computer enthusiasts and power users.

1  
Did you try from:"@google.com" ? –  BrianAdkins Feb 23 '13 at 19:57
    
Yes, from:"@google.com" unfortunately works the same as from:@google.com. It really seems like gmail is ignoring the @ sign. –  studgeek Feb 24 '13 at 16:10

1 Answer 1

What you can use is a Google Script that does regex match with the TO field to find emails with an exact domain in the address:

function myFunction() {

  var label = GmailApp.getUserLabelByName("Google.com");
  if (!label) label = GmailApp.createLabel("Google.com");

  var threads = GmailApp.search("from:google.com");
  for (var t in threads) {
    var msg = threads[t].getMessages()[0];
    if (msg.getTo().match(/\@google\.com/)) {
      threads[t].addLabel(label);
    }
  }

}

Also see: Advanced Gmail Search with RegEx

share|improve this answer
    
I like the idea, and it eliminated txt.voice.google.com, but for some reason I still see plus.google.com. I've looked at the original message and it sures looks to me like your trick should work. The From line is From: "Google+" <noreply-2xxxxxxb@plus.google.com> –  studgeek Feb 24 '13 at 16:07
    
PS, Thanks for your blog. It's helped me out in the past :). –  studgeek Feb 24 '13 at 16:07
    
Actually, it doesn't seem to be working me at all now. It seems like the search engine ignores the periods. –  studgeek Mar 1 '13 at 16:49
1  
Unfortunately, I does not work. I've started a bounty, hoping for answers... –  Krzysztof Wolny Aug 6 at 15:44
1  
See my updated answer. –  Amit Agarwal Aug 6 at 19:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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