# ***NEW*** own subroutine for mail sending sub mail_it { my $mailtext = shift; my $to = 'chris@localhost'; my $from = 'root@localhost'; my $subject = 'Test Email from decrypt.pl'; my $email = Email::Simple->create( header => [ To => $to, From => $from, Subject => $subject, ], body => $mailtext, ); sendmail($email); # open( my $mailer, "|-", "/usr/sbin/sendmail -t" ) # or die "Could not open sendmail: $!"; # one print to print it all # print $mailer <<"END_OF_MESSAGE"; #To: $to #From: $from #Subject: $subject #$mailtext #END_OF_MESSAGE # close( $mailer ) or die "Close sendmail failed: $!"; # print "Email Sent Successfully\n"; }