Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to send htmlified mail in perl 1

Status
Not open for further replies.

khoont

Programmer
Mar 9, 2001
10
US
HI,

i m looking for hint how to send mail with html inside through perl. i m using send function but i dont know how to use this to send htmlified mail.

Thanks
khoont
 

Some other guy just asked that a few pages back, so if you want to see how with sendmail look for that post, lately I sitched over to MIME::Lite however, and I think it makes my code look neater.

$message = qq~
<html>
This is my html message
</html>
~;
use MIME::Lite;
$msg = MIME::Lite->new(
From =>'me@yahoo.com',
To =>'someone@hotmail.com',
Subject =>'A Test Message',
Type =>'text/html',
Data =>&quot;$message&quot;
);
$msg->send; # Send the message

If you don't have MIME::Lite on your server, you can of course just use sendmail, but also you could download MIME::Lite from cpan.org and just put Lite.pm in your directory with your script and instead of use MIME::Lite; put

require &quot;Lite.pm&quot;;

That's what I did and it works like a charm.

Also, if you use Mime Lite you can send attachments on a dime.

$msg = MIME::Lite->new(
From =>'me@yahoo.com',
To =>'you@hotmail.com',
Subject =>'A Test Message',
Type =>'multipart/mixed'
);
$msg->attach(Type =>'TEXT',
Data =>&quot;MY NEW TEST!!!&quot;
);
$msg->attach(Type =>'image/gif',
Path =>&quot;$path/test.gif&quot;,
Filename =>'test.gif',
Disposition => 'attachment'
);
$msg->attach(Type =>'image/gif',
Path =>&quot;$path/test2.gif&quot;,
Filename =>'test2.gif',
Disposition => 'attachment'
);

$msg->send; # send the message

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top