Skip navigation.
Home
Your source for Perl tips, howto's, faq and tutorials
( categories: )

You can easily send html emails from Perl using MIME::Lite; it's very simple, lightweight and gets the job done.

MIME::Lite is not included in a standard perl installation, so you have to install the module from CPAN using this command:

cpan -i MIME::Lite

Optionally, if you are on Debian, you can install it using apt-get:

apt-get install libmime-lite-perl

Here's some sample script:

#!/usr/bin/perl
use MIME::Lite;
 
$body = "<h1>html email using perl</h1> This is the body of the message";
 
#-- initialize the object
$msg = new MIME::Lite(Subject=>'html email', To=>'user1', Type=>'text/html', Data=> $body);
 
#-- send the message
$msg->send();