WebTechKitchen; Your Web Technology Kitchen, contact us to create, or maintain your websites and other digital properties.

sending mail with Perl and sendmail

Submitted by barnettech on Wed, 12/16/2009 - 13:47

#!/usr/bin/perl
print "Content-type: text/html\n\n";
 
$title='Perl Mail demo';
$to='MAIL ADDRESS TO SEND TO';
$from= 'webmaster@YOURDOMAIN.COM';
$subject='YOUR SUBJECT';
 
open(MAIL, "|/usr/sbin/sendmail -t");
 
## Mail Header
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
## Mail Body
print MAIL "This is a test message from Cyberciti.biz! You can write your
mail body text here\n";
 
close(MAIL);
 
print "$title\n\n\n";
 
## HTML content sent, let use know we sent an email
print "
$title
 
A message has been sent from $from to $to
 
";