#! /usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use strict ;
my $sendmail = "/usr/sbin/sendmail -t";
my $send_to = "To: target\@gmail.com\n";
my $from = "From: myuser\@mydomain.x10hosting.com\n";
my $subject = "Subject: PERL/SENDMAIL TEST\n\n";
my @it = getpwuid( $> ) ;
open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
print SENDMAIL $send_to;
print SENDMAIL $from;
print SENDMAIL $subject;
print SENDMAIL "Test script sending cron job/web via perl. Info: @it";
close(SENDMAIL);
print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<HEAD><TITLE>Hello World!</TITLE></HEAD>\n";
print "<BODY>\n";
print "<H2>Hello World!</H2> <br /> \n";
print "<H3>UID: $> effective $< real @it</H3>" ;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,
$yday,$isdst)=localtime(time);
printf "\n%4d-%02d-%02d %02d:%02d:%02d\n",$year+1900,$mon+1,$mday,$hour,$min,$sec;
foreach my $key (sort keys(%ENV)) {
print "\n<p>$key = $ENV{$key}</p>" ;
}
print "</BODY>\n";
print "</HTML>\n\n\n\n";