How to filter Gmail messages to labels on advanced headers?

321 views
Skip to first unread message

Robert Andrews

unread,
Dec 9, 2020, 6:38:32 AM12/9/20
to Google Apps Script Community
Gmail's in-built search feature does not apparently support advanced headers.

I would Gmail to automatically identify messages matching certain criteria. Namely, those which come via but not from distribution services like PRNewswire and Gorkana.

Take the following header from one such message...

ARC-Authentication-Results: i=1; mx.google.com;
       spf
=pass (google.com: domain of sprbounce+b32$vzzjfltltby3gn4q5jhxjipjsi======@gorkanadatabase.com designates 85.158.142.4 as permitted sender)
smtp
.mailfrom="sprbounce+B32$VZZJFLTLTBY3GN4Q5JHXJIPJSI======@gorkanadatabase.com"
Return-Path: <sprbounce+B32$VZZJFLTLTBY3GN4Q5JHXJIPJSI======@gorkanadatabase.com>
Received-SPF: pass (google.com: domain of sprbounce+b32$vzzjfltltby3gn4q5jhxjipjsi======@gorkanadatabase.com designates 85.158.142.4 as permitted sender) client-ip=85.158.142.4;
Authentication-Results: mx.google.com;
       spf
=pass (google.com: domain of sprbounce+b32$vzzjfltltby3gn4q5jhxjipjsi======@gorkanadatabase.com designates 85.158.142.4 as permitted sender) smtp.mailfrom="sprbounce+B32$VZZJFLTLTBY3GN4Q5JHXJIPJSI======@gorkanadatabase.com"
Return-Path: <sprbounce+B32$VZZJFLTLTBY3GN4Q5JHXJIPJSI======@gorkanadatabase.com>
X
-Env-Sender: sprbounce+B32$VZZJFLTLTBY3GN4Q5JHXJIPJSI======@gorkanadatab
  ase
.com
Received: from unknown (HELO vmx-grk-mta02.durrants.co.uk) (195.248.81.102)
 
by server-24.tower-223.messagelabs.com with DHE-RSA-AES256-SHA encrypted SMTP; 1 Oct 2020 07:09:55 -0000
Received: from [10.12.107.23] (helo=vms-pes03.durrants.co.uk) by vmx-grk-mta02.durrants.co.uk with esmtp (Exim 4.71) (envelope-from <sprbounce+B32$VZZJFLTLTBY3GN4Q5JHXJIPJSI======@gorkanadatabase.com>) id 1kNsih-0004AI-Do for mail@mydomainnamehere.co.uk; Thu, 01 Oct 2020 08:09:39 +0100

We could choose to check the field "Received-SPF" for the string "gorkanadatabase".

How can this be done with Script?

I have seen that it is possible to use Scripts to check and apply labels to incoming Gmail messages - eg. https://www.labnol.org/internet/advanced-gmail-filters/4875/

But I don't understand how to implement this in my case.

Thank-you.
Message has been deleted

CBMServices Web

unread,
Dec 14, 2020, 11:00:19 AM12/14/20
to google-apps-sc...@googlegroups.com
Such filtering is much lower in the Google code base and not made available as far as I know.

These are the controls that Google uses to accept, reject or flag spam emails to the overall user base.

They would not want us disturbing that process.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/54a0dddd-6276-41c8-b0ef-fe7939e5501bo%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages