procmail
[Top] [All Lists]

Re: Bad Mail

1996-11-21 18:10:04
:0
* ^TO.*me
! tbac(_at_)mail(_dot_)idt(_dot_)net



I want to set up something that will send this email to 
"postmaster(_at_)mydomain(_dot_)com" but also return the email as 
undeliverable. Just like in "real life" when you send email 
to someone and the name is misspelled, etc.

        FROM=`$FORMAIL -rt -xTo:`
        DOMAIN=`echo $FROM | sed -s 's/^.*\@//'`

        :0
        * ^TO.*me
        |(formail -r -A"Precedence: junk"\
        -I"From: <postmaster(_at_)mydomain(_dot_)com> "\
        -I"To: postmaster(_at_)$DOMAIN"
        _I"Cc: $FROM"
        -I"Subject: Undeliverable" \
        -A "X-Loop: postmaster(_at_)mydomain(_dot_)com";\
        cat $FILEDIR/badadd.txt )|$SENDMAIL -t

But many of these (I presume) idiots are sending the mail from "rogue 
sites" and ones without <postmaster> accounts (giving the middle finger 
to the RFCs I guess), so a better way is:

        :0
        * ^TO.*me
        { EXITCODE = 77 HOST }

I'm sure you could combine these two recipes to send the "badadd.txt" to 
the <postmaster(_at_)$DOMAIN> and "EXITCODE = 77" it to the sender.  I'll 
leave that as an exercize to the reader :^>  X-LOOP and DAEMON checks 
should probably be escaped as you did in the other recipe.

I have this, which send a reply letter and copies the original
email to my box, but it doesn't send back the email or any
reference. I guess I'm looking for the proper way to return
misaddressed email.

I'm not sure what you mean by "misaddressed mail" because if it gets to 
you isn't it "addressed properly"?  The proper way would be to reject it 
via the proper SENDMAIL EXICODE I would think if it is a non-existant user.

Lates!
------------------------------------
Tim <bodysurf(_at_)netcom(_dot_)com>
"Finger" for PGP v2.6.3ia Public Key