I’m trying to use Perl to send an email message. Basically I have a Perl script that prints out a report in a nice format. I want that report to be sent via email. How can I
Simplest way without CPAN libraries:
#!/usr/bin/perl
$to = 'toAddress@xx.com'; # to address
$from = 'fromAddress@xx.com'; # from address
$subject = 'subject'; # email subject
$body = 'Email message content';# message
open(MAIL, "|/usr/sbin/sendmail -t");
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
print MAIL $body;
close(MAIL);
print "Email Sent Successfully to $to\n";