[Mimedefang] Filtering on sender, recipient, and subject at the same time

McCarthy, Douglas J dmccart at intel.com
Thu Jul 7 01:33:57 EDT 2005

Hi -

	I'm using MD 2.44.

	What I'm trying to do is prevent automatically-generated mail
from vacation-notification applications from going outside the company I
work for.  The logic I'm using in the filter_recipient subroutine in 
mimedefang-filter is basically:

if ($sender =~ /@mycompany.com>?$/i) {
    if ($recipient !~ /@mycompany.com>?$/i) {
        if ($Subject =~ /Out of Office Autoreply/) { #Exchange vacation
            return ('DISCARD', "ok");
        if (system("egrep '(^User-Agent: Vacation/|^X-Mailer: vacation
)' $CWD/HEADERS")) {                                    # UNIX vacation
            return ('DISCARD', "ok");
if ($ip =~ /list.of.internal.systems'.IP.addresses.here/) {
    return ('ACCEPT_AND_NO_MORE_FILTERING', "ok");
return ('CONTINUE', "ok");

I'm having a lot of problems with this.

First off, the system(egrep) call isn't working.  It's returning a 
"mimedefang-multiplexor[NNNN]: Slave N stderr: grep:
/var/spool/MIMEDefang/mdefang-aNNNaaaaNNNNNN/HEADERS: No such file or
directory" error.  This doesn't seem right, because from what I can
tell, that directory is indeed the right place for the HEADERS file to
be.  (Specifying ./HEADERS instead of $CWD/HEADERS doesn't work either.)

Second off, $Subject isn't available from within filter_recipient.  This
would be okay, if I could egrep for the subject from the HEADERS file...
but I can't, because of the "No such file or directory" error above.

Any help you could give me would be greatly appreciated!

More information about the MIMEDefang mailing list