era eriksson writes on 26 May 1997 at 17:03:07
On Mon, 26 May 1997 11:15:13 +0200 (MET DST),
Bernard El-Hagin <sokrates(_at_)sound(_dot_)eti(_dot_)pg(_dot_)gda(_dot_)pl>
wrote:
[...]
If this won't work for attachments how do I filter out mail that's too
large because of attachments?
How about something like
:0
* > 10000
* ^Content-type:
* ! ^Content-type:[ ]*(text|message)
{
EXITCODE=77
HOST
}
This should generate a bounce instead of just make the message
Here's what I've set up to deal with large messages.
Dan
------------------- message is author's opinion only ------------------
J. Daniel Smith <DanS(_at_)bristol(_dot_)com>
http://www.bristol.com/~DanS
Bristol Technology B.V. +31 33 450 50 50, ...51 (FAX)
Amersfoort, The Netherlands {info,jobs}(_at_)bristol(_dot_)com
-----
#####
##### trap large messages. VM and Emacs start getting real sluggish
##### when folders get over a few megabytes. Plus, if I'm away on
##### vacation or just not checking mail for a few days (long
##### weekend), a few large messages could quickly fill up my disk
##### causing all kinds of yucky mail problems. More than likely I'd
##### prefer such "large" messages by some other means (FTP, HTTP,
##### message/external-body, etc.) anyway.
#####
##### Do this here (before mailing list processing) - in case some
##### spammer decides to mailbomb a list, or a bozo/newbie sends it
##### large messages
#####
# 50K is about 1000 lines under normal circumstances, it's easy to
# truncate using "head". Don't use "procmail"'s scorring to actually
# count lines - actual size is more important than lines (although I
# can't think of an easy way to truncate to 50K).
MAXSIZE=50000
# truncate large messages to this many lines (head -$MAXLINES)
MAXLINES=1000
:0B
* $ > ${MAXSIZE}
{
# I'm lazy...some of this stuff was here before
N=${MAXLINES}
# let procmail do the work of pitching the headers, reduce the
# current message body to just $N lines
#
# Here's why the 'i' flag is needed (courtesy of Stephan):
# You told procmail to filter the entire mail (header and body), so it
# does and it attempts to write out header and body to the filter.
# Then procmail notices that not the entire body is being consumed.
# Procmail, being rather paranoid when it comes to delivery of mail
# assumes something went wrong and considers this a failure of the filter.
:0wifb
| head -$N
# Drop the "Content-Length:" header since its no longer accurate.
# Add a note to the beginning of the message telling the reader that
# its been truncated
:0wfh
| formail -I "Content-Length:" ; \
echo "[large message truncated to $N lines]" ; echo ""
# tell the sender I truncated their message, but only if it was
# sent explictly to me (and not some mailing list). Should whine to
# *anybody* within ${DOMAIN} too - they should know better; but
# that might cause problems with things forwarded from Lotus Notes
:0Whc:large.lock
* $^TO${ME_REGEXP}
* !^FROM_DAEMON
* $!^X-Loop: ${UNIQUE_NAME}
| expired -t8h .large.cache "${SENDER}"
:0 ehc
{
# don't put the exact sizes in the auto-response, makes it
# too easy for someone to send something one character smaller
:0fi
| formail -rt -I "Precedence: junk" -A "X-Loop: ${UNIQUE_NAME}" ;\
echo "This is to let me know that the message you sent" ;\
echo "to ${TO_LINE} about ${SUBJECT}" ;\
echo "was too large and thus has automatically been TRUNCATED." ;\
echo "" ;\
echo "More than likely, I would prefer to receive this message" ;\
echo "by some other means; please contact me so that we can work" ;\
echo "out the necessary arrangements. Kindly accept my apologies" ;\
echo "for any inconvenience this may cause you." ;\
echo "" ;\
echo "Thanks for your understanding and cooperation," ;\
echo " Dan" ;\
cat ${HOME}/.signature
:0
! -oi -t
}
}