Назад | Перейти на главную страницу

Создать фильтр 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 "test1@example.com" or $sender_address is "test2@example.com"
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 

У меня это работает. Для всех, кто хочет сделать что-то подобное, вот что я использовал:

# 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