|
|
current directory: home / linux |
| [site tree] |
(12/26/1999) i like my email to be text. ascii text. wrapped at 80 columns. call me old fashioned, but i find it simpler and easier to read when it's confined by these not-unreasonable boundaries. i don't feel the need to look at the one-paragraph-per-line format that comes out of some mailers or to have animated gifs jumping at me.
this used to be no problem when most of my contacts were digerati who were as equally flame-prone as i was when someone posted html to our lug mailing list. then i started getting a fair bit of html mail from people who didn't know how to configure their mail clients to send plain text, nor even that such a thing was an option or why it would be desirable. worse still, i started getting a lot of press releases in msword format. i even went to work for a company filled with administrative staff who happily typed away in ms office all day and shared their output with everyone from time-to-time. what to do with a company email list that comes in the form of an excel spreadsheet?...
as much as i don't like getting such mail, i like even less having to take the time to launch helper apps or save files and run converters on them. and what if i'm sshed from somewhere, and don't have the option of running abiword to see what it is? i could pipe the mail through strings, but ick. why should i have to bother?
my solution has been to automate the handling of such mail so it changes into the form i like without my having to even know it was ever anything else.
the three non-text formats i get most often in my mail are html, msword, and msexcel. the mail user agent i use, vm, allows me to tell it how to convert certain mime types to other mime types. so, i tell it this in its configuration file:
(setq vm-mime-type-converter-alist
'(
("text/html" "text/plain" "$HOME/bin/w3m-stdin.sh")
("application/msword" "text/plain" "$HOME/bin/mswordview-stdin.sh")
("application/x-msword" "text/plain" "$HOME/bin/mswordview-stdin.sh")
("application/msexcel" "text/plain" "$HOME/bin/xlhtml-stdin.sh")
("application/x-msexcel" "text/plain" "$HOME/bin/xlhtml-stdin.sh")
))
in other words, "change everything into plain text, using these scripts for each conversion." i'm sure mutt users, who are always bragging about how they can use hooks to do anything, can set up something similar, and i would imagine that the same thing can be done in pine, which is far more configurable than it seems once you get beyond the defaults.
vm expects that the conversion will take place this way: vm will decode the attachment and send it off as stdin to the process of your choice, then incorporate the result into the message as a section of the mime type you specified. because of this, all the scripts below are made to work on stdin; you may have to futz with them if your mail client wants something different.
i am not going to launch x and then netscape just to see that someone has sent me "hi there!" in bold red type. i change the html to text with the amazing text-based browser w3m. the script i use is:
tmpfile=$HOME/.vm-htmldoc-tmp.html cat - > $tmpfile w3m -dump $tmpfile
simple enough, eh? but the results are wonderful. have a look:
now when i'm running my laptop, there's no need to waste battery life by starting x just to see what this mail's all about.
for word documents, i simply convert the offending attachment to html and do the same thing to it. for the html conversion, i use mswordview, like this:
tmpfile=$HOME/.vm-worddoc-tmp.doc htmlfile=$HOME/.vm-worddoc-tmp.html cat - > $tmpfile mswordview -o $htmlfile $tmpfile w3m -dump $htmlfile
which gives me:
there have been several occasions on which i didn't even realize at first that a message had ever contained a word document at all. that made me very happy. :)
i convert spreadsheets to html with xlhtml, then again to text with w3m, like this:
tmpfile=$HOME/.vm-exceldoc-tmp.xls htmlfile=$HOME/.vm-exceldoc-tmp.html cat - > $tmpfile xlHtml -c $tmpfile > $htmlfile w3m -dump $htmlfilethis is where w3m's table rendering really shines. check it out:
i'll leave a final thought with system administrators: would this be something worth doing with all the mail that comes into your system? imagine this: a piece of mail comes into your system with an attachment of which you don't approve. maybe it's a spreadsheet; maybe it's a .exe file. the appropriate script strips it from the message and puts it in safekeeping somewhere where the user can't get it, then replaces it with a message from you explaining what's happened and that if the recipient really needs the original file, she should contact you. (followed by a text version of the file, if appropriate.)
what does this buy you? immunity from viruses. the user can't run the untested executable if she never receives it, and can't open a melissa-tainted document with macros enabled if she only has the text of it. anyone who wants her files has to first wait for you to open them on a test machine off the network.
here's a copy of procmail. happy hacking! :)
| comments (0) | contact me |
this page was last updated on: 2006-06-23 08:44:03 |
all of the original content on this website is available under the creative
commons attribution-sharealike
license.