On 07Jun2019 23:22, Kurt Hackenberg <k...@panix.com> wrote:
On 2019-06-07 07:22, Cameron Simpson wrote:
If fetchmail's delivering to a programme, nothing prevents that being an arbitrary script to premangle a leading From_ line. Hmm. I've got a script in my bin directory called "unfrom_" for exactly this purpose, which reads:

 #!/usr/bin/env sed -f
 #
 # Transmute leading "From " line on email message, if any.
 #    - Cameron Simpson <c...@cskk.id.au> 13jul2002
 #

 1{s/^From /From_: /}

You can just include that script in a pipeline ahead of maildrop.

Yep.

I've also seen From_ lines in maildir message files, and on the stdin of delivery agents. Both are wrong, in my opinion. I think mbox From_ lines should not exist anywhere outside mbox files.

Well, the From_ isn't just a delimiter for mbox lines, it also historically contains the envelope address from the mail system - the address used for this delivery (versus whatever may be in the headers). So it has some useful forensic information.

I've written a script much like yours, to drop the damn From_ line from an incoming message passed to a delivery agent. I think your script does something that's not quite right: it transforms the mbox From_ line to something that's not RFC 822. You could do, say,

   s/^From /X-Mbox-From: /

I'm digging through RFC 8522:

 https://tools.ietf.org/rfcmarkup/5322

which is the modern incarnation of RFC822, but it doesn't seem very prohibitive on header field names. Section 2.2 says:

Header fields are lines beginning with a field name, followed by a colon (":"), followed by a field body, and terminated by CRLF. A field name MUST be composed of printable US-ASCII characters (i.e., characters that have values between 33 and 126, inclusive), except colon.

This is confirmed in section 3.6.8:

 optional-field  =   field-name ":" unstructured CRLF
 field-name      =   1*ftext
 ftext           =   %d33-57 /          ; Printable US-ASCII
                     %d59-126           ;  characters not including
                                        ;  ":".

So I think "_" is permitted :-)

Or -- my recommendation -- just drop it. (Of course, drop it only if that first line really is an mbox From_ line.)

I'm a hoarder and dislike discarding anything.

Cheers,
Cameron Simpson <c...@cskk.id.au>

Reply via email to