Skip navigation.
Your source for Perl tips, howto's, faq and tutorials

send html email

( 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:

sending mail with attachments

( categories: )

To send mail with attachments, create a multipart message using MIME::Lite module.


check whether a host is reachable through the network

( categories: )

Use the Net::Ping module:

use Net::Ping;
my $host = "";
my $p = Net::Ping->new();
print "$host is reachable\n" if ( $p->ping($host) );

sending mail from a Perl script

( categories: )

There are many ways to send e-mails using Perl. One simple way is to use the module Mail::Send:

use Mail::Send;
$body = "This is the body of the message";
#-- initialize the object
$msg = new Mail::Send Subject=>'example subject', To=>'user1', Cc=>'user2@host';
#-- launch mailer and set headers
$fh = $msg->open;
#-- print the message body
print $fh "Hello,\n";
print $fh "$body\n";
#-- complete the message and send it

connect to a ftp server

( categories: )

Use Net::FTP module. The functions are named like the corresponding ftp commands, so it's very easy to use.


Syndicate content