procmail
[Top] [All Lists]

Re: Bouncing Bad Addresses

2002-06-29 15:14:19
In this case, the server is dedicated to one (very active) domain and is 
about as powerful as an Intel-Linux box can be.  If this were an account 
on a shared server, I wouldn't have done half of the things I did in 
scripting and mailing.

Being a good citizen is always a consideration.

Keep in mind, that if you get 100 pieces of spam to bad addresses in a
minute, which happens to me on a regular basis, you just may see your
machine get a bit unhappy.  Avoid perl in mass usage IMHO.  I've seen it go 
awry.

I'm gonna look into that procmail recipe, as my perl solution, like yours,
ended up a bit troublesome.

Give it a try, en mass :)

On Sat, 29 Jun 2002, Tom Most wrote:

Sean:

I gave a sincere effort to apply your recipe but, in the end, I found it 
best
to play to my strong suit: Perl.  It was a lot easier to pipe the header and
body to <STDIN>, do a couple GREP's and substituations to pull the info
I needed, and send the response.  30 lines of code in a scripting
language I understand was much better than 30 lines in Procmail (which
makes me crazy).

However, I appreciate your assistance.

Tom

At 14:32 2002-06-28 -0700, Tom Most wrote:
I need to create a bounce recipe which will be at the end of a rather
lengthy .procmailrc that will bounce any other email which does not
match any email address in .procmailrc.  All addresses on this server are
routed though Procmail.

I'd advise against that.  Spam will probably make up the bulk of those
bounces, and since the MTA has already accepted the message, in order to
bounce, you'll have to initiate a fresh SMTP connection - versus just
declining to accept the message.

Furthermore, this implies that you may be trying to use Procmail as an MTA
- something which Procmail is not well suited to.  BCCs and multiple local
recipients will bite you every time.  You should use the MTA as an MTA.

I have written the recipe through the point of extracting the From: and
changing the To: to the from value, rewritting the Subject: (Delivery
Failure), and placing a short message explaining that the address is
invalid in the body.

Joy, yet another form of bounce message for mailing lists to attempt to
make sense of.  Please at a bare minimum, attempt to make it look just 
like
a sendmail-generated MTA bounce for user unknown - down to the DSN values.

What has me stumped: I would like to echo the original header and body
at the end of the new body.  Any suggestions?


Basically:

:0
| ( cat sometemplatefile - | formail options ) | $SENDMAIL recipient

Or something similar.  OTOH, you could have a template file that isn't
static text but rather contains tokens which you replace - the recipient
name (which I trust you have some magical way of pulling out of the ether
at a non-MTA delivery stage) and your hostname for instance:


[auto-reply/BOUNCEUNKUSER]
This is an automatically generated Delivery Status Notification.

Delivery to the following recipients failed.

        %RECIPIENT%



Reporting-MTA: dns;%MYHOST%
Received-From-MTA: dns;%MYHOST%
Arrival-Date: %DATE%

Final-Recipient: rfc822;%RECIPIENT%
Action: failed
Status: 5.0.0
Diagnostic-Code: smtp;550 unknown user <%RECIPIENT%>

[end auto-reply file - not including these delimiters]


# You should deal with your own mail looping.
# Set LOOPALERT as appropriate.
# set AUTOREPLY to the dir where the template would be found.
# Set REPLYTO to the address which you're going to send the bounce to.

BOUNCEMSG=BOUNCEUNKUSER
BOUNCESUBJ="Delivery Status Notification (Failure)"
BODYBOUNCE=y
BOUNCER="postmaster(_at_)your(_dot_)domain(_dot_)tld"
INCLUDERC=bouncer.rc
#------------------



# [bouncer.rc]
# BOUNCEMSG = message file for bounce message (just the filename, we
#       expect to find it in $AUTOREPLY/)
# BOUNCESUBJ = subject text for the bounce message.
# BODYBOUNCE = if non-null, this causes the BODY of the message to be
#       bounced, but not the outer message (usually used for admin bounces
#       such as nonmember submissions)

# if BODYBOUNCE isn't empty, set the option to 'b' for processing the BODY
:0
* ! BODYBOUNCE ?? ^^^^
{
         BODYBOUNCE=b
}

:0$BODYBOUNCE
* $! REPLYTO ?? @(127\.0\.0\.1|localhost)\>
* $! REPLYTO ?? ^[      ]*(mailer-daemon|postmaster)@
| ( sed -e "s/%RECIPIENT%/$RECIPIENT/" \
         -e "s/%MYHOST%/`hostname --fqdn`/" \
         -e "s/%MYHOST%/`date "+%a, %e %b %Y %T %z"`/" templ.1 | \
         formail -I "Subject: $BOUNCESUBJ" \
         -I "To: $REPLYTO" \
         -I "X-Loop: $LOOPALERT" \
         -I "From: $BOUNCER" ; sed -e "1d" ) | $SENDMAIL -t -f $BOUNCER

# Execution will fall here only if preceeding wasn't run,
# due most likelt to an issue with reply address.
# (do whatever you will with failed messages)


The above is extracted from some code of mine, and while the larger script
from which it is used works great, the above as-is is not tested, as per 
my
disclaimer.  Make sure your hostname and date support the gnu extensions
used here, or find an alternate (the date string could be extracted from
the From_ line of the received message - technically, that would be
slightly more appropriate, but hey - you're using Procmail as an MTA, so
what does it matter?).

Note: if you return a recipient name which isn't the same as the actual
envelope recipient, the sender will be perplexed at what address really
failed.  This sort of BS is annoying for list administrators who have to 
do
a bunch of testing to figure out what address which is subscribed to their
list is causing the bounce.  Consider carefully whether this approach is
correct.

---
  Sean B. Straw / Professional Software Engineering

  Procmail disclaimer: 
<http://www.professional.org/procmail/disclaimer.html>
  Please DO NOT carbon me on list replies.  I'll get my copy from the 
list.

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail



-- 



This is a registered WASHINGTON STATE email address, sending unsolicited
commercial email with any fraudulent or misleading content will prompt action
by the Attorney General of Washington State.

Register your email address now, go to http://www.registry.waisp.org/

Do NOT add this address to any mailing lists or your address will be blocked.


Thank You for your Cooperation.



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>