This is a small filter-style utility written in “C” that adds a header to each message indicating the size of the message in megabytes, with each asterisk indicating one megabyte (or a fraction) as:
X-actualmessagesize: *
as well as a header indicating the message size in bytes as:
X-actualmessagesizebytes: 268289
It’s purpose in life is to prevent large messages from causing problems with downstream software that can’t handle large messages. For example, some versions of Exchange and some servers with limited hardware would choke on very large messages.
To build, download the AddMsgSizeHeader.c file and Makefile, then run “make”
The app runs as a filter, and adds a spamassassin-style X-MessageSize header containing 1 asterisk (*) for each MB, up to a max of 50, and a header containing the actual message size in bytes (as a number). Messages can be any size, however it stops calculating the size after 50MB.
To use it, add
/^X-ActualMessageSizeBytes.*/ WARN
/^X-ActualMessageSize.*\*\*\*\*\*/ HOLD
to your postfix header_checks file. this will hold anything more than
5MB and add a log entry.
You can then release the messages using postsuper -H
The utiltiy will handle any size message, although the X-actualmessagesize header has a limit of 50 asterisks in order to not violate the RFC for line length.
Although this software has been running beautifully for a long time in a busy production server, it comes with absolutely no warranty of any kind, and is provided completely free of charge.
- Author: Terry Carmen — terry@cnysupport.com
- Released to the public domain 9/21/2007
- No warranty or representations of any kind are made.
- It may operate perfectly, or break into your apartment while you’re sleeping, drink all your beer and eat all your cold pizza.
If you like it, please let me know. If you don’t like it, please let me know why.
Thanks,
Terry
————————————————————————–
Usage: Add to master.cf:
filter unix – n n – – pipe user=filter argv=/usr/bin/spamc -e /usr/sbin/ContentFilter -oi -f ${sender} ${recipient}
————————————————————————–
Create the ContentFilter script as:
#!/bin/bash
EX_TEMPFAIL=75
EX_UNAVAILABLE=69
/usr/sbin/AddMsgSizeHeader X-ActualMessageSize | /usr/sbin/sendmail “$@” ${sender} ${recipient} || { echo AddMsgSizeHeader failed;exit TEMPFAIL; }
exit 0
——————————————–
