简体   繁体   中英

Using procmail to copy emails to another address and altering “from”

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM