如何也使procmail转发和密件抄送

如何也使procmail转发和密件抄送

本文介绍了如何也使procmail转发和密件抄送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将符合特定模式的电子邮件转发到一组地址,并将同一电子邮件密件抄送给其他一些电子邮件地址.通过查看我的procmail日志,似乎我的所有规则都匹配,但是密件抄送收件人没有收到该消息.

I'm trying to forward e-mails matching a certain pattern to a set of addresses, and BCC the same e-mail to some other e-mail addresses. From looking at my procmail log, it appears that all my rules are matching, yet the BCC recipient does not receive the message.

.procmailrc的相关行如下所示:

The relevant lines of my .procmailrc look like this:

:0fhw
* ^From.*@example.com
* ! ^X-Loop: test
| formail -A "Bcc: $BCCS"

:0fhw
* ^From.*@example.com
* ! ^X-Loop: test
| formail -A "X-Loop: test"

:0
* ^From.*@example.com
* ! $DEST ?? ^$
! $DEST

到达procmailrc的这一部分时,BCCS变量包含BCC的地址,而DEST变量包含要转发到的地址.

At the point this part of the procmailrc is reached, the BCCS variable contains the address(es) to BCC, and the DEST variable contains the address(es) to forward to.

在日志中,我看到这样的内容:

In the log I see something like this:

procmail: Match on "^From.*@example.com"
procmail: Match on ! "^X-Loop: test"
procmail: Executing "formail,-A,Bcc: [email protected]"
procmail: Match on "^From.*@example.com"
procmail: Match on ! "^X-Loop: test"
procmail: Executing "formail,-A,X-Loop: test"
procmail: Match on "^From.*@example.com"
procmail: Match on ! "^$"
procmail: Executing "/usr/sbin/sendmail,-oi,[email protected],[email protected]"
procmail: Assigning "LASTFOLDER=/usr/sbin/sendmail -oi [email protected],[email protected]"
procmail: Notified comsat: "michael@:/usr/sbin/sendmail -oi [email protected],[email protected]"

似乎正在添加密件抄送:"标头,并且按预期发送了电子邮件.从我的研究中得出的结论是,我需要向BCC转发一个"Bcc:"标头,然后sendmail将邮件复制到它指定的任何地址,并在实际发送的邮件中删除"Bcc:"标头电子邮件.但是我不确定100%,因为我发现的有关BCC的所有问题都与希望在 incoming 消息上触发BCC的人有关,如果配置了发送服务器,则无法真正做到这一点正确地.

It appears that a Bcc: header is being added and the e-mail forwarded as I expect. My assumption from what I have gathered from my research is that to BCC in the forward I need to add a "Bcc:" header, and sendmail will copy the message to any addresses it specifies and strip the Bcc: header off in the actually sent e-mail. However I am not 100% sure, as all the questions I have found regarding BCC deal with people wanting to trigger on BCC on the incoming message, which can't really be done if the sending server is configured properly.

我做错什么了吗?

推荐答案

formail -A "Bcc: $BCCS"添加一个密件抄送:"标头. ! $DEST将消息转发到"$ DEST",但是,! ...将忽略"Bcc:"头. ! ...的有效运作方式类似于密件抄送(除非没有添加和删除标头).除了第3条转发规则,您可以使用2条规则,第1条对邮件的副本起作用(请注意第1条规则中的 c 标志):

formail -A "Bcc: $BCCS" adds a "Bcc:" header. ! $DEST forwards the message to "$DEST", however, ! ... will ignore the "Bcc:" header. ! ... effectively works like Bcc (except there is no header added and removed). Instead of your 3rd forwarding rule you can use 2 rules, where the 1st works on a copy of the message (note the c flag in the 1st rule):

:0 c
* ^From.*@example.com
* ! $BCC ?? ^$
! $BCC

:0
* ^From.*@example.com
* ! $DEST ?? ^$
! $DEST

另一种选择是sendmail -t.它从邮件标题中读取收件人,因此它还将看到您的密件抄送:"标题并相应地处理该邮件.我建议不要使用sendmail -t,除非总的来说,除非您有一个非常受控的环境,以确保您不需要的消息中没有"To:","CC:"和"BCC:"标头

An alternative is sendmail -t. It reads recipients from the mail headers, so it would also see your "Bcc:" header and process the message accordingly. I'd advise against using sendmail -t though in general unless you have a very controlled environment where you are sure there are no "To:", "CC:" and "BCC:" headers in the messages that you don't want.

默认情况下,Procmail使用sendmail,而不使用sendmail -t.因此,您必须像在

Procmail by default uses sendmail, not sendmail -t. So, you'd have to pipe the message to sendmail -t like in

:0
* ^From.*@example.com
* ! $DEST ?? ^$
| sendmail -i -t $DEST

这篇关于如何也使procmail转发和密件抄送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 19:44