创建 exim 过滤器以将外发电子邮件限制为有限的几封

创建 exim 过滤器以将外发电子邮件限制为有限的几封

我试图限制用户向几个选定域之外的任何域发送电子邮件,本例中为 outlook.com 和 gmail.com,我一直在尝试使用类似下面的过滤器,但只要包含 gmail/outlook,这将允许将邮件发送到任何域!我的大脑就是无法让它工作!

任何帮助都将不胜感激,谢谢。

# Exim filter
#
# test1 & test2 are not restricted
# test3 & test4 are restricted to @outlook.com and @gmail.com, i.e. cannot send to any other domain

# these email addresses are not restricted
if $sender_address is "[email protected]" or $sender_address is "[email protected]"
then
    finish
endif

if $sender_address_domain is "example.com" and ("$h_to:, $h_cc:, $h_bcc:" does not contain "@outlook.com" and "$h_to:, $h_cc:, $h_bcc:" does not contain "@gmail.com") 
then
    fail text "Sorry one or more of your email recipients is not allowed."
    finish
endif 

答案1

我成功了。对于任何有兴趣做类似事情的人,以下是我使用的方法:

# Exim filter
#
# test1 & test2 are not restricted in this example

if $sender_address_domain is "example.com" 
    # these email addresses are not restricted
    if $sender_address_local_part is "test1" or $sender_address_local_part is "test2" #etc
    then
        finish
    endif

    if foranyaddress $recipients ( $thisaddress does not contain "@allowed1.com" and $thisaddress does not contain "@allowed3.com" and $thisaddress does not contain "@allowed3.com" ) #etc
    then
        fail text "Email blocked. One or more of your email recipients is not allowed."
        finish
    endif
endif

相关内容