I get email alerts that are generated by a user on one of my servers. These alerts are generated by server@######.com and they have to do with third party software not working properly.
I'm trying to use procmail to copy (as I want to keep receiving these) these emails to ABC@XYZ.com.
I'm looking for emails that, in their body, have "C:" followed by 6 characters, a dot, and 3 more characters. All of that is working fine, but I want the third party to get these emails from me bruno@XXXXXX.com rather than server.
How can I copy the email to a third party AND change the from address to be bruno@XXXXX.com?
Here's the procmail file:
cat .procmailrc
DROPPRIVS=yes
LOGFILE=$HOME/procmail.log
:0 c:
* B ?? C:......\....
! ABC@XYZ.com
:0 B:
* ^To: .*alerts@XXXXXX.com
! bruno@XXXXXX.com
Inject the headers you want with formail
before piping to sendmail
. (Recall that !
is basically a shorthand for | $SENDMAIL $SENDMAILFLAGS
.)
Do I understand correctly that the first recipe is the one you would like to modify?
:0 c # No lockfile when forwarding
* B ?? C:......\....
| formail -I 'From: bruno@XXXXXX.com' \
| $SENDMAIL $SENDMAILFLAGS ABC@XYZ.com
Your second recipe similarly should not have a lock file; see http://www.iki.fi/era/procmail/mini-faq.html#locking