email, html, images, text, links vs embedded...
Brian K. White
brian at aljex.com
Thu May 12 16:52:16 PDT 2005
Just figured I'd share a few interesting things I've learned recently.
A few people have expressed interest in something I've mentioned a few times
lately.
Attached is a simple version of a bash script that sends an email.
It's not intended to be a finished product to use as-is, although it does
work fine.
It's meant to be a reference of how to do a couple neat things.
The interesting points are:
1) takes command line arguments for recipient address, subject, one or more
text files and one or more image files. gets "from" address from the env
variable MYMAIL. Intention being MYMAIL is set once during login and used
many times at will.
2) takes plain text or pcl text such as from an output format and wraps it
in html "pre" tags so that it lines up correctly in gui email clients that
would have otherwise displayed it in a proportional font.
3) takes full page image files of any format/resolution and base64 encodes
them into mime attachements
4) writes a body text in html that includes the txt files, followed by IMG
tags that display the image files
5) the html includes css commands to control page-breaks. a page break is
inserted before every txt or img file.
this means when printed, the fp output and scanned docs all print sanely,
and there is a 'wasted' sheet at the beginning that has the
headers/letterhead that the email client inserted.
The text files are just assumed to be 80-ish columns wide. I don't know of a
good way to ensure that wide text doesn't chop off to the right when
printed.
Probably it can be done by testing line lengths and inserting a font size
tag to compensate. Food for future development.
Images are printed "100% width" which magically makes them fill a page if
they were a full page to start with. Shrunken a little due to the header,
footer, & margins that the email client/browser applies.
it's also the most natural way to view the image on-screen. it results in
one vertical scroll bar and you just maximize the window to zoom in enough
to read the small print if necessary.
The main point is the script shows how to do a few interesting things:
1) page-breaks in html
2) embedding images in an email in such a way that they:
a) display in-line right in the email, no acrobat or other image viewer
if you use one of the standard browser image formats (gif, jpg, png, etc...
not tiff, ps, etc...)
b) are physically present in the email and so not reliant on your web
server, your net connection, or the recipient net connection all being up
both now and forever in the future.
c) are not blocked by recent versions of outlook express, which quite
rightly block html tags in emails from downloadig things, includuing images,
from remote web servers by default.
d) intentionally don't look like "attachements" in outlook express. no
paperclip. or you can tweak one line and have them look like attachements.
It's intentionally a simple script so that the key html/mime magic that
makes the above work is easy to follow, rather than have the script clogged
with lots of other features and sanity checking etc...
You can add all that at will, and/or impliment the actions all directly in
filepro processing instead of bash, etc.
It's quite lightweight and fast. The base64 conversion handles a fair chunk
of data when it takes a 100k jpg and base64's it, but it's really doing
almost no work. Little more than "cat".
The rest of it is all just catting and echoing a little text. the unpcl &
ibm2ascii commands are just 1 & 2 line sed scripts, also very light & fast.
(unpcl & ibm2ascii, and bash for that matter, can be found at
http://www.aljex.com/bkw/sco)
Crude benchmarking had a given sample set of 3 or 4 pcl & 3 or 4 image files
taking on average 30 seconds per image and 2 seconds per page of text, to
generate a pdf equivalent of what this puts out, whereas this generated and
sent the same set of images & text in 3/10ths of one second for the whole
job. Repeated in different orders too, so it's not due to the 2nd test
benefitting from any caching effects.
It's this combination of client side convenience and server side efficiency
that are why I so often preach "Don't give the customers pdf email without
trying real hard to educate them away from it unless the content actually
does require it."
It also shows the basics of creating an email file and submitting it
directly to sendmail in place of running a mail client like "mail" or mutt,
pine, etc... but I don't claim that's new or interesting for most here.
Brian K. White -- brian at aljex.com -- http://www.aljex.com/bkw/
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro BBx Linux SCO Prosper/FACTS AutoCAD #callahans Satriani
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mailinvc
Type: application/octet-stream
Size: 1827 bytes
Desc: not available
Url : http://lists.celestial.com/pipermail/filepro-list/attachments/20050512/c49c9c00/mailinvc.obj
More information about the Filepro-list
mailing list