Re: [exim] Discard mail to certain recipients if the subject…

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Chris Siebenmann
Date:  
À: Александр Кириллов
CC: Chris Siebenmann, Exim-users
Sujet: Re: [exim] Discard mail to certain recipients if the subject matches a string
> Thanks for your attention, guys, but here's my problem -
>
> The messages (commit notifications) must be delivered to some
> recipients but not the others. I don't have access to the headers in
> acl_smtp_rcpt and in acl_smtp_data I can discard the entire message to
> all its recipients as mentioned above by Mike.
>
> This is all about outgoing mail. The recipients are not local and
> those I need to block belong to a known customer domain.
>
> I have some weird thoughts about routing mail to this domain through
> a relay which would take care of the content filtering but it's too
> complicated unless the mail can be somehow rerouted through that same
> MTA.


When you need to selectively discard some but not all recipients after
the message has been received, what you probably want is a system filter
run from a router. Something like:

    spam_discard:
        # possibly conditional on sender(s) as well
        domains = +special_domains
        local_parts = DISCARD_USERS
        driver = redirect
        file = /etc/exim4/exim-spam-filter
        no_verify
        allow_filter
        allow_freeze
        user = Debian-exim


And then the filter would be something like:

    # Exim filter
    logfile /var/log/exim4/discardlog
    if $h_subject MATCHES ...
    then
        logwrite "$tod_log $message_id discarded ..."
        seen finish
    endif


Since the filter is run from a router it is run separately for each
individual destination address, and it can discard some but not all
of them.

If you want to generate errors instead of silently discarding the
message, I believe that you don't even need a system filter; just
write a router that forces an error for the appropriate destination
addresses under the appropriate conditions. The trick here is that
you want a router with:
    allow_fail
    data = :fail:<insert message here>


(I guess you can also use the pure-router approach to silently
discard messages by 'delivering' them to /dev/null or the like.)

    - cks