[H-GEN] Send html page via email in PERL??

Jason Parker-Burlingham jasonp at uq.net.au
Thu Mar 27 19:25:58 EST 2003


[ Humbug *General* list - semi-serious discussions about Humbug and     ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]

"Tony Melia (DMS)" <Tony.Melia at downsmicro.com.au> writes:

> I need to send a web page to an email address via PERL (Redhat 8).

That'd be "Perl" (or "perl"), not "PERL".  Thanks so much.

> I need functionality similar to IE6's 'send page via email' option
> which, given a URL, will send a html email message which consists on
> the web page at the URL, complete with images in a format identical
> to what would be seen on screen in a browser.

Well, does IE6 really send the images, etc., or does it just send the
HTML and let the recipient's mail client download the images as
needed?

> Is there any modules for doing this?

Uh, well, sure:

        LWP::Simple             -- to fetch the Web resources you need
        Mail::Mailer            -- to write and send your email
        MIME::Lite              -- to make your attachments, etc.

(In fact MIME::Lite has an entry in the Perl FAQ (see perlfaq9.pod).)

> I can only see MIME related
> ones that rely on you knowing in advance what images e.t.c will be
> in the web page.

Well to be honest I have a hard time thinking of how you will fetch
the images to be able to send them to the recipient without knowing in
advance what they are and where to find them.

I suppose a pretty basic algorithm might look like this:

fetch the web page source, add it to the MIME message
for each resource which would be displayed on-screen
   fetch the object, remember the content-type header
   make a MIME object of that type with that object's content
   add that MIME object to the message
   tweak the email's HTML source to refer to the object just added
check the content types and lengths
send the email!

The only catch is I do not know how to change that HTML to refer to
the images attached to the message, but I bet you could look at some
spam (yeah, spam) to find out how, or reverse-engineer the IE6
feature.

> I have a web page which makes pretty graphs and tables, but need it to be
> sent via email, and this is the only way I think I can do it.

Um, by any chance can you simply send the graphs and tables with some
explanatory text?  That's sure to be a whole lot easier and
potentially less prone to security violations.

["Region has 32 lines, 1490 characters"...uh, that's quite a
disclaimer you have there, big boy.]
-- 
uck Wa!

--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.  See http://www.humbug.org.au/



More information about the General mailing list