Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using filter for return-path

Tags:

gmail

I am getting mail where "From" and "Reply-to" are different than "Return-Path", "Received from" as shown in this example. How do I set filter for such mail?

Return-Path: <[email protected]>
Received: from bhasha.interpole.net (bhasha.interpole.net. 
Received: from cybersho by bhasha.interpole.net with local (Exim 4.77)
    (envelope-from <[email protected]>)
From: "Gadima.com" <[email protected]>
Reply-to: "Gadima.com" <[email protected]>
like image 456
shantanuo Avatar asked Jul 19 '12 10:07

shantanuo


1 Answers

It doesn't seem to be possible in Gmail, unfortunately.

I fell back to my email client, Gnus (because of its amazing flexibility and lightness) to do this. The details are explained in the "6.3.3 Client-Side IMAP Splitting" section of its manual.

It was surprisingly easy. In my ".gnus.el" file, I put (I'm using the nnimap backend for Gmail) something like this:

(setq nnimap-split-methods
 '(("mail-list-folder" "Return-Path: mail-list-address")
   ("INBOX" ""))

You'd need to adapt your "mail-list-folder" (label) and "Return-Path: mail-list-address" parts accordingly. The string containing "Return-Path: ..." is a regexp so can you can use wildcards such as .* and even groups. For example, to filter some lists I'm subscribed to, I have:

(setq nnimap-split-methods
 '(("list.\\1" "^Return-Path: <\\(.*\\)-bounces.*@gnu.org>")
  ("INBOX" ""))

Notice the capture group, \\(.*\\) which is used to form my label, as well as the adaptations required to match the Return-Path as formed by the mailing list program.

If you'd like to try it out I can suggest the following wiki to get started: https://www.emacswiki.org/emacs/GnusGmail.

like image 112
Apteryx Avatar answered Oct 26 '22 18:10

Apteryx