Remove second "\n" from the line below. Sendmail treat first empty line as "end of headers".
print MAIL "Subject: $subject\n\n";
Additional fixes:
- add
-i
command line options to avoid special treatment of lines starting with dot - specify recipients as command line arguments passed to sendmail after
--
command line option - check sendmail exit code as returned by
close
- use single print with "here document"
print MAIL <<"END_OF_MESSAGE";
Reply-to: $reply
From: $from
To: $to
Subject: $subject
X-Priority: 1
blah blah blah
$link
END_OF_MESSAGE