firstname.lastname@example.org (John Wiegley) asks "how to interpose a
filter between a mailer and sendmail" (because he'd like to make sure
lines are kept to no more than 72 characters). The rough trick is to
get the mail transfer agent (e.g., sendmail) to recognize which messages
this should be done with (based on the sender and recipient), run the
message through the appropriate filter, and then deliver the message.
If you can express this at all, the main trick is to avoid infinite
recursion of the rewrite rule. (I did this once with an SVR4 mail
surrogate, but I don't remember the details.)
email@example.com (Michael C. Berch) suggests using a filter between the
mail user agent (e.g., Mail or mailx) and the message transfer agent.
This is certainly simpler. He also points out running the whole message
through a filter doesn't work; you (usually!) don't want to filter the
header lines. I have a filter (for the user agent, not the transfer
agent) that passes through all lines up to and including the first line
with no non-blank characters (e.g., up to the first empty line), and
then does interesting things with the remaining lines.
Michael also asks:
> BUT, what I don't understand is why you need this -- essentially every
> modern text editor, whether it's vi or emacs or Word Perfect or or
> whatever, does "word wrap", that is, where you type continuously and it
> take care of the newlines for you. And any reasonable mail program on
> a UNIX box that I've seen lets you choose what editor you want to use
> to compose mail with. Am I missing something?
One user's "reasonable" is another person's "lousy". I'll give two
examples. First, some people do use word wrap, but they set the length
of the line to the width of their terminal (or terminal window); this
often exceeds 100 characters. (This can be a problem with vi, which
defines the wrap margin as a distance from the right; this varies
depending on the width of the terminal.) Second, at least one user
agent (the one in Sun OpenWindows 3.0) wraps on the screen without
wrapping lines in the file being sent; the sending user *thinks* the
lines look nice, and a receiving user with the same user agent does,
too; everyone else gets one line per paragraph.
Everyone seems to think that sendmail is the only reasonable UNIX-based
message transfer agent. I've found that /bin/mail in SVR4 is very
nice. It can match address patterns the way sendmail can, but never
has such "deep" tree of decisions at any one time. (SVR4 has a program
called "sendmail"; it's used only for transport over TCP/IP, in the
same way uux is used for transport over uucp links.) If you want
nothing to do with "commercial" operating systems (from such vendors as
Sun and HP/Apollo), feel free to sneer. If your UNIX platform is
moving toward SVR4 (a direction even OSF has endorsed), I think you'll
find the new mail transport agent to be very nice.
Paul S. R. Chisholm, AT&T Bell Laboratories/EasyLink Services,
att!pegasus!psrc, firstname.lastname@example.org, AT&T Mail !psrchisholm
I'm not speaking for my employer, or for the guys who now hold the
trademark on the word UNIX; I'm just speaking my mind.