The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

MIME::Lite::HTML - Provide routine to transform a HTML page in a MIME-Lite mail

SYNOPSIS

  use MIME::Lite;
  use MIME::Lite::HTML;
  
  my $mailHTML = new MIME::Lite::HTML
       From     => 'MIME-Lite@alianwebserver.com',
     To       => 'alian@jupiter',
     Subject => 'Mail in HTML with images';
     
  $MIMEmail = $mailHTML->parse('http://www.alianwebserver.com');
  $MIMEmail->send; # or for win user : $mail->send_by_smtp('smtp.fai.com');

DESCRIPTION

This module provide routine to transform a HTML page in MIME::Lite mail. The job done is:

 =over

 =item Get the file (LWP)

 =item Parse page to find include images
 
 =item Attach them to mail with adequat cid
 
 =item Include external CSS,Javascript file
 
 =item Replace relative url with absolute one

 =back

It can be used by example in a HTML newsletter. You make a classic HTML page, and give just url to MIME::Lite::HTML.

VERSION

$Revision: 0.6 $

METHODS

new(%hash)

Create a new instance of MIME::Lite::HTML.

%hash can have this key : [Proxy], [Debug], [HashTemplate] Others keys are use with MIME::Lite constructor.

This MIME-Lite keys are: Bcc, Encrypted, Received, Sender, Cc, From, References, Subject, Comments, Keywords, Reply-To To, Content-*, Message-ID,Resent-*, X-*,Date,MIME-Version,Return-Path, Organization

$hash{'HashTemplate'} is a hash too. If present, MIME::Lite::HTML will substitute <? $name ?> with $hash{'HashTemplate'}{'name'} when parse url to send.

parse($url, [$url_txt])

Subroutine used for created HTML mail with MIME-Lite

 $url   : Url of HTML file to send. Can be a local file. 
 Example : http://www.alianwebserver.com, file://c|/tmp/index.html

Return the MIME::Lite part to send

include_css($gabarit,$root)

(private)

Search in HTML buffer ($gabarit) to remplace call to extern CSS file with his content. $root is original absolute url where css file will be found.

include_javascript($gabarit,$root)

(private)

Search in HTML buffer ($gabarit) to remplace call to extern javascript file with his content. $root is original absolute url where javascript file will be found.

input_image($gabarit,$root)

(private)

Search in HTML buffer ($gabarit) to remplace input form image with his cid

Return final buffer and list of MIME::Lite part

(private)

Replace link to formulaire with absolute link

fill_template($masque,$vars)

 $masque : Path of template
 $vars : hash with keys/val to substitue

Give template with remplaced variables Ex: if $$vars{age}=12, and $masque have

  J'ai <? $age ?> ans, 

this function give:

  J'ai 12 ans,

AUTHOR

Alain BARBET alian@alianwebserver.com