First, Liviu Daia suggested,
D> Yes. Fortunately, it can be fixed with procmail:
D> :0 Bfh
D> * $ H ?? ^Content-Length:
No need for the dollar sign, but it does no damage. But don't you want to
do this on messages where the Content-Length: header is ABSENT? If it
already has one, procmail will correct the number in it.
D> * 1^1 .
D> * 1^1 ^.*$
D> * -1^0
It turns out that there is a better way to get the size of the body:
* 1^1 B ?? > 1
D> | formail -I "Content-Length: $="
Then Era Eriksson replied,
E> Actually, it's even simpler than that. Without the -Y flag, Procmail
E> will fix any wrong Content-Length headers. Just run any messages
E> through Procmail. If you want to force them to have a Content-Length
E> (which Procmail subsequently fixes), add one with formail:
E> :0fhw # yeah, note the w flag (or isn't it required here?)
E> * ! ^Content-Length:
E> | formail -I"Content-Length: 00000000"
The `w' flag can't hurt. On a filtering recipe it tells procmail to recover
the previous text if the filter returns failure.
E> The standard caveat here is to make the field wide enough to allow
E> Procmail to fix the number without making the physical line longer.
Well, you can always take care of that by allowing for ten digits, since
procmail can't count beyond 2^32 anyway, and nobody should be sending
things that large by email. You can also plug it by force to make sure the
width is exact, though you may want to allow room for one extra digit in
case a subsequent filter lengthens the body past a power of 10:
:0fhw # B won't help; size conditions ignore H and B flags on the :0 line
* ! ^Content-Length:.*[0-9]
* 1^1 B ?? >1
| formail -a "Content-Length: $="
[Yes, a space does work, at least when I tried it under procmail 3.11pre7
and FreeBSD.]