Sending email using Perl using sendmail
Posted
by
i.h4d35
on Stack Overflow
See other posts from Stack Overflow
or by i.h4d35
Published on 2013-11-10T09:50:44Z
Indexed on
2013/11/10
9:53 UTC
Read the original article
Hit count: 507
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.
© Stack Overflow or respective owner