diff options
author | Richard Nelson <cowboy@debian.org> | 1998-06-23 10:00:00 -0500 |
---|---|---|
committer | Andreas Beckmann <debian@abeckmann.de> | 2012-10-01 19:58:37 +0200 |
commit | 6202a816311c5e56f71ecd358850b1e6d8cd7065 (patch) | |
tree | de47ad4f657df101b6f36a07a6c6e19191be7de9 /mmuegel/src/postclip | |
parent | 6c193ce1dd1d07ebdc1372e38bc4908ab1c37705 (diff) | |
download | sendmail-6202a816311c5e56f71ecd358850b1e6d8cd7065.tar.gz |
Imported Debian patch 8.8.8-20debian/8.8.8-20
Diffstat (limited to 'mmuegel/src/postclip')
-rw-r--r-- | mmuegel/src/postclip | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/mmuegel/src/postclip b/mmuegel/src/postclip new file mode 100644 index 0000000..63f6df0 --- /dev/null +++ b/mmuegel/src/postclip @@ -0,0 +1,74 @@ +#!/usr/local/bin/perl + +# NAME +# postclip - send only the headers to Postmaster +# +# SYNOPSIS +# postclip [ -v ] [ to ... ] +# +# AUTHOR +# Michael S. Muegel <mmuegel@mot.com> +# +# RCS INFORMATION +# /usr/local/ustart/src/mail-tools/dist/foo/src/postclip,v +# 1.1 of 1993/07/28 08:09:02 + +# We use this to send off the mail +require "newgetopts.pl"; +require "mail.pl"; + +# Get the basename of the script +($Script_Name = $0) =~ s/.*\///; + +# Some famous constants +$USAGE = "Usage: $Script_Name [ -v ] [ to ... ]\n"; +$VERSION = "${Script_Name} by mmuegel; 1.1 of 1993/07/28 08:09:02"; +$SWITCHES = "v"; + +# Let getopts parse for switches +$Status = &New_Getopts ($SWITCHES, $USAGE); +exit (0) if ($Status == -1); +exit (1) if (! $Status); + +# Who should we send the modified mail to? +@ARGV = ("postmaster") if (! @ARGV); +$Users = join (" ", @ARGV); +@ARGV = (); + +# Suck in the original header and save a few interesting lines +while (<>) +{ + $Buffer .= $_ if (! /^From /); + $Subject = $1 if (/^Subject:\s+(.*)$/); + $From = $1 if (/^From:\s+(.*)$/); + last if (/^$/); +}; + +# Do not filter the message unless it has a subject and the subject indicates +# it is an NDN +if ($Subject && ($Subject =~ /^returned mail/i)) +{ + # Slurp input by paragraph. Keep track of the last time we saw what + # appeared to be NDN text. We keep this. + $/ = "\n\n"; + $* = 1; + while (<>) + { + push (@Paragraphs, $_); + $Last_Error_Para = $#Paragraphs + if (/unsent message follows/i || /was not delivered because/); + }; + + # Now save the NDN text into $Buffer + $Buffer .= join ("", @Paragraphs [0..$Last_Error_Para]); +} + +else +{ + undef $/; + $Buffer .= <>; +}; + +# Send off the (possibly) modified mail +($Status, $Msg) = &Send_Mail ($Users, "", $Buffer, 0, $opt_v, 1); +die "$Script_Name: $Msg\n" if (! $Status); |