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

[亡魂溺海] 提交于 2019-12-12 03:24:00

问题


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

回答1:


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



来源:https://stackoverflow.com/questions/33674229/using-procmail-to-copy-emails-to-another-address-and-altering-from

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!