Quoting Kimmo Jaskari (kimmo(_at_)alcom(_dot_)aland(_dot_)fi):
Does anyone have a nice way to make messages that are sent in HTML format
bounce with a note stating why it bounced and what they can do about it?
And no, I wasn't thinking about a suggestion to insert the message or a
paper copy thereof in the anatomical orifice of their choice. ;)
First method (a fairly standard bounce script):
* ^Content-Type:[ ]+text/html
| (formail -r -t -I"From: Your Name <you(_at_)your(_dot_)domain>"\
-I"Subject: no html here";
cat /path/bounce.message) | $SENDMAIL -t
For this, you'll also need a bounce.message, which is a text file
containg whatever you want. Alternatively, if you don't want an external
file, you can replace the cat with echo's. If you want to include the
original for reference, you'll need something a bit clunkier:
* ^Content-Type:[ ]+text/html
| formail -r -t -I"From: Your Name <you(_at_)your(_dot_)domain>"\
-I"Mime-Version: 1.0" \
-I"Content-Type: multipart/mixed; boundary=FL5UXtIhxfXey3p5"\
-I"Subject: no html here"
| cat /path/html.bounce.top.txt - /path/html.bounce.bottom.txt
| $SENDMAIL -t
For this, you'll also need a html.bounce.top.txt:
I'd prefer not to receive html emails. The most common program generating
such emails is Netscape Communicator. If you don't know how to turn off
html messages, here's how...
As well as an html.bounce.bottom.txt:
(Does anyone know of a way to save the headers? Or a cleaner way of
doing the above?)
As a rule, I favour non-autoreplying recipes, but HTML messages are
getting more common as newbies grab Netscape and merrily start mailing,
and I'd like to point out to those same newbies that I can't easily read
HTML in Pine and how they can disable that 'feature' in their browser.
You should be able to fire up a copy of lynx to read the message in pine
by adding a .mailcap to your home directory containing:
text/html; lynx -force_html %s; needsterminal; description=HTML Text;
Alternatively, if someone knows a good way to strip the html tags from a
message and turn it into plain old text I would appreciate tips.
Well, you can use a perl or somesuch filter in place of lynx in the
.mailcap, if you want to convert after delivery. Alternatively, you can
use something like this:
* Content-Type:[ ]+text/html
| formail -I "Content-Type: text/plain"
| sed 's/<[^>]*>//g'
This is a pretty gross conversion; all it does is change the type to
text/plain and strip out every tag. If you do use something like this,
you run the risk of losing information. (But most people that send
html-only mail aren't using it for anything but plain text anyway.) I'd
recommend the .mailcap solution, but you can use a stripper if you
really don't care much about html messages.
On this topic (and relating back to the earlier question about saving
headers), is there a way to get more than one copy of the body? It
occurs to me that one possibly cleaner way of handling this situation
would be to use a simple script to strip off the tags and then build a
multipart/alternative with the original html so that no information is
lost. I couldn't think of a good way to do that from procmail without
running it through perl et al.
Michael Stone, Sysadmin, ITRI PGP: key 1024/76556F95 from mit keyserver,
mstone(_at_)itri(_dot_)loyola(_dot_)edu finger, or email with
"Subject: get pgp key"