如何防止邮件发送到postfix别名自动回复发送?

我有一个有20个邮件帐户的别名。 所以当邮件发送到这个别名,每个人都收到它。 但是,当我在这20个邮件帐户中的一个上设置了休假时,自动回复也被发送。 我想排除这些情况 – 邮件中没有特定的邮件帐户在收件人:或抄送:头。 该脚本被称为vacation.pl,它来自postfixadmin。

除了手动编辑脚本之外,有什么办法可以做到吗?

最简洁的答案是不”。 至less如果你的设置和脚本与我的类似。


今天我仔细看看了我们和Postfixadmin结合使用的vacation.pl。

我认为这是一样的,但是人们永远无法确定,所以要小心。 在脚本的第一行中,对于版本说明如下:

# Virtual Vacation 4.0 # $Revision: 893 $ 

在我们的例子中,自动回复的激活在postfix的别名表中增加了一个如下的条目:

 [email protected]@autoreply.example.org,[email protected] 

这意味着电子邮件将保存到用户的邮箱并转发到autoreply域(autoreply.example.org)。

在transportmap中有一个如下的入口,它将邮件传递给master.cf中定义的休假服务:

  autoreply.example.org vacation: 

为了完整,这里是我的master.cf中的条目:

 vacation unix - nn - - pipe flags=Rq user=vacation argv=/var/spool/vacation/vacation.pl -f ${sender} ${recipient} 

这意味着,在parsing别名后触发vacation.pl脚本。

所以,如果你想阻止自动回复电子邮件,已经发送到一个别名,你将需要添加一个函数的脚本,这将检查X原件到头,所以你可以确保如果邮件是发送给有多个收件人的别名。


在第312行附近定义了函数find_real_address。 此function将search真实地址(用户)。

如果电子邮件地址不是多个收件人的别名之一,则可以使用修改后的版本此function与X-Original-To-Header中的电子邮件地址组合发送自动回复。


我还没有尝试任何上述build议,所以要小心。

这一切都取决于你的假期回复是在哪里产生的; 通常,这是通过链接到用户邮箱的.forward文件中的脚本来完成的。

由于这不适用于虚拟邮箱,因此有多种select – 使用专用filter,传输,MDA或更多。

也许更多。

您必须提供更详细的信息,包括至lesspostconf -n的输出和任何与此场景相关的映射文件。

还包括logging正在发送到此分配列表别名的消息,以及生成的消息,包括休假回复。

我正在寻找同样的东西,我使用Webmin运行我的电子邮件服务器,autoreply邮件是使用脚本/etc/webmin/virtual-server/autoreply.pl

通过阅读它,我发现这个块:

 if ($header{'x-mailing-list'} || $header{'list-id'} || $header{'precedence'} =~ /junk|bulk|list/i || $header{'to'} =~ /Multiple recipients of/i || $header{'from'} =~ /majordomo/i || $fromline =~ /majordomo/i) { # Do nothing if post is from a mailing list exit 0; } 

所以我添加了其他条件$header{'to'} =~ /my_alias_name_here/i || 这样它永远不会发送自动回复到任何电子邮件发送到该别名。

这是一个快速的黑客,也许我会有一段时间后,使其列出服务器的所有别名。 如果你之前做过,请分享脚本:)

我们通过改变两件事来解决上述问题:

1)将原始收件人而不是后缀的收件人传递给vacation.pl脚本:

 vacation unix - nn - - pipe flags=Rq user=vacation argv=/usr/lib/postfixadmin/vacation.pl -f ${sender} -- ${recipient} vacation unix - nn - - pipe flags=Rq user=vacation argv=/usr/lib/postfixadmin/vacation.pl -f ${sender} -- ${original_recipient} 

2)修改vacation.pl脚本,使其不发送包含多个收件人的别名的假期消息。

 #MC my $vemail = $email; #MC $vemail =~ s/\@/#/g; #MC $vemail = $vemail . "\@" . $vacation_domain; #MC $logger->debug("Looking for alias records that '$email' resolves to with vacation turned on"); #MC my $query = qq{SELECT goto FROM alias WHERE address=? AND (goto LIKE ? OR goto LIKE ? OR goto LIKE ? OR goto = ?)}; #MC $stm->execute($email,"$vemail,%","%,$vemail","%,$vemail,%", "$vemail") or panic_execute($query,"address='$email'"); $logger->debug("Looking for alias records that '$email' resolves to with vacation turned on"); my $query = qq{SELECT goto FROM alias WHERE address=?}; my $stm = $dbh->prepare($query) or panic_prepare($query); $stm->execute($email) or panic_execute($query,"address='$email'"); $rv = $stm->rows; 

 #MC do not send away-message to alias with multiple recipients # for (split(/\s*,\s*/, lc($alias))) { # my $singlealias = $_; # $logger->debug("Found alias \'$singlealias\' for email \'$email\'. Looking if vacation is on for alias."); # $rv = check_for_vacation($singlealias); ## Alias has vacation # if ($rv == 1) { # $realemail = $singlealias; # last; # } # } $logger->debug("Found multiple aliases \'$alias\' for email \'$email\'. Thus, not sending vacation reply."); $realemail = $email; $rv = 0;