I'm looking for code to create HTML E-mail. I'd rather not re-invent anything if possible, though my search for such a beast has turned up nothing that does quite what I want. About the closest is SimpleMail, but it does not handle inline images, which is critical.
(I've also started looking at RubyMail, though I haven't seen any indication that it supports inline image references.)
What I would *really* like is something that takes as input an HTML string and a hash of header values (to, from, subject, etc.), and creates the multipart/alternative E-mail by magic.
Ideally, it would create a plain text version, followed by the HTML version. If the HTML contains any relative URLs, they would be interpreted as local file paths; the file would be slurped in, uuencoded, and added to the E-mail as a multipart/related segment, and the img href value then converted to a cid: reference.
I've done some hacking about on my own, munging up a copy of SimpleMail, but before I go too far I thought I'd just check to see if someone beat me to it.
Any tips or pointers appreciated; please, no lectures on the evils of HTML E-mail; this is for a specific project for people who actually *request* such E-mail.
Thanks!
James
I'm looking for code to create HTML E-mail. I'd rather not re-
invent anything if possible, though my search for such a beast has
turned up nothing that does quite what I want. About the closest is
SimpleMail, but it does not handle inline images, which is critical.
I do HTML emails regularly, using tmail. They, however, are simple straight
HTML mails and not multipart/MIME.
What I would *really* like is something that takes as input an HTML
string and a hash of header values (to, from, subject, etc.), and
creates the multipart/alternative E-mail by magic.
That would be _fantastic_. I would use such a thing quite often. I never
did find anything like that, however, when I was doing my checking. I
strongly encourage you to continue on your hacking down this path, as you
have one eager user awaiting your results already!
Kirk Haines
···
On Sun, 18 Jul 2004 10:43:12 +0900, James Britt wrote
For dis/assembling MIME email, look over
http://freshmeat.net/projects/mboxsh/
by yours truly.
You can create text version using Lynx. But, if you only have HTML
file, then including local file and images are messy to do, because you
have to parse HTML to figure out what path to include. It would be a
bit easier if you already know what file or image to include in MIME
email.
···
James Britt <jamesUNDERBARb@neurogami.com> wrote:
I'm looking for code to create HTML E-mail. I'd rather not re-invent
anything if possible, though my search for such a beast has turned up
nothing that does quite what I want. About the closest is SimpleMail,
but it does not handle inline images, which is critical.
(I've also started looking at RubyMail, though I haven't seen any
indication that it supports inline image references.)
What I would *really* like is something that takes as input an HTML
string and a hash of header values (to, from, subject, etc.), and
creates the multipart/alternative E-mail by magic.
Ideally, it would create a plain text version, followed by the HTML
version. If the HTML contains any relative URLs, they would be
interpreted as local file paths; the file would be slurped in,
uuencoded, and added to the E-mail as a multipart/related segment, and
the img href value then converted to a cid: reference.
I've done some hacking about on my own, munging up a copy of SimpleMail,
but before I go too far I thought I'd just check to see if someone beat
me to it.
Any tips or pointers appreciated; please, no lectures on the evils of
HTML E-mail; this is for a specific project for people who actually
*request* such E-mail.
--
William Park, Open Geometry Consulting, <opengeometry@yahoo.ca>
Toronto, Ontario, Canada
William Park wrote:
For dis/assembling MIME email, look over Best Open Source Mac Software Development Software 2024
by yours truly.
I shall do that now!
You can create text version using Lynx. But, if you only have HTML
file, then including local file and images are messy to do, because you
have to parse HTML to figure out what path to include. It would be a
bit easier if you already know what file or image to include in MIME
email.
Actually, I think that part would be fairly easy. My plan was to pass the source HTML through the REXML stream or pull parser and emit a plain-text version (possibly wrapping pseudo-markup, such as *bold* or /italics/, when encountering specific tags.) At that time, any img element can be parsed for the src attribute. If the URL doesn't start with http then the code assumes a local relative file. The file is grabbed, uuencoded, a CID ref generated for it, and the CID put in place of the original src value.
Or something along those lines.
(Actually, this presumes the source markup is XHTML, not HTML. An alternative my be to use the htmlparser lib, but then the code starts acquire 3rd-party dependencies. )
James