Sending email using Perl using sendmail
- by i.h4d35
I am following the example from this website to send an email using Perl. The code looks like so:
my $hostname = `hostname`;
my $this_day = `date`;
my $email = "i.h4d35\@gmail.com";
my $to = "$email";
my $from = "admin\@$hostname";
my $subject = "SCHEDULE COMPLETE - $this_day";
my $message = "Student schedule for today, completed for the following students: \n\n$names\n\nHave a nice day...";
open(MAIL, "|/usr/sbin/sendmail -t");
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
print MAIL $message;
close(MAIL);
The mail gets sent but the subject appears in the body of the mail and the email has no subject. How do I fix this?
PS: Have not gotten around to using MIME::Lite yet as I am still learning this.