When Gmail forwards an email to an external address, it apparently inserts the forwarded address into the FROM line. So an email being forwarded to username@school.edu by username@gmail.com becomes:
username+caf_=username=school.edu@gmail.com
I'm having trouble matching this resulting FROM address in procmail. I've tried these match patterns with no success:
:0
* ^From:.*username\+caf_=username=school.edu@gmail.com
/dev/null
:0
* ^From:.*username.*@gmail.com
/dev/null
The second pattern should match anything between username and @gmail.com, but its failure makes me think that procmail is having trouble processing the FROM string to be searched and that the problem is not with the match pattern at all. Note that the procmail log sees and reports the modified FROM address without any issues, just like it does with any email that didn't match the pattern.
Any ideas on how to match these types of forwarded gmail addresses? Thanks.
Here's the abbreviated header of the email in question:
From username+caf_=username=school.edu@gmail.com Sat Nov 10 11:26:24 2018
X-Received: by 2002:a2e:1241:: with SMTP id --;
Sat, 10 Nov 2018 11:25:20 -0800 (PST)
X-Forwarded-To: username@school.edu
X-Forwarded-For: username@gmail.com username@school.edu
Delivered-To: username@gmail.com
X-Google-Smtp-Source: --
X-Received: by 2002:ac8:7598:: with SMTP id s24mr13601716qtq.6.1541877918711;
Sat, 10 Nov 2018 11:25:18 -0800 (PST)
From: someuser <someuser@someagency.gov>
Date: Sat, 10 Nov 2018 14:24:59 -0500
To: username@someagency.gov
Subject: TEXT
User-Agent: Heirloom mailx 12.4 7/29/08