0

I have an existing procmail recipe to forward a copy to my gmail account that is working well:

:0c
! myAddress@gmail.com

I have a second rule that is also working well (in limited testing) to prefix the subject with [OLD DOMAIN]:

:0fwh
* (To|Cc).*oldDomain.com
* ^Subject:\/.+
| formail -I"Subject: [OLD DOMAIN]$MATCH"  

The issue is in my local email account I get the modified subject as expected, but not in my gmail account. How can I combine these rules or modify the forward and copy rule to change the subject?

tripleee
  • 175,061
  • 34
  • 275
  • 318
dawydiuk
  • 17
  • 3

1 Answers1

0

Just reverse their order; make sure the one which rewrites the subject runs before the one which forwards a copy to Gmail.

Procmail simply processes your .procmailrc from top to bottom for each incoming message, and stops processing it once a (non-cloning) delivering action is successful. The c flag says to clone the message (so, even though the clone is successfully delivered, continue processing the original copy).

As an aside, the regex for (To|Cc) should probably have a ^ anchor in front, unless you specifically want to match the text anywhere in a header line.

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • Thanks so much that does what I want in my .procmailrc file!! Question, I'd like to roll this out to everyone. Could I add the recipe to change the subject in /etc/procmailrc so it changes the subject for everyone. My hope would be this gets parsed first then ~/.procmailrc would get parsed next where I could have the recipe to forward a copy to my gmail address. I can always test this out, but hating testing in a live environment so figured it's best to ask first :) – dawydiuk Sep 21 '22 at 14:08
  • Your exposition seems rather terse, but it sounds like it should work without any issues. For testing before you go live, maybe see also https://www.iki.fi/era/mail/procmail-debug.html – tripleee Sep 21 '22 at 14:22