Below script works fine in my Linux server.
(
echo "From: name@xyz.com";
echo "To: name2@xyz.com";
echo "Subject: Test Subject";
echo "Content-Type: text/html";
echo "MIME-Version: 1.0";
echo "";
echo "<html><head><title>HTML E-mail</title></head>
<body><p>Test Body Message</p></body></html>";
) | sendmail -t
But after modify the script as below, it shows error as "No recipient address found in header". Is it possible to workout the below code using variable. I don't want to use any file or any other mail command except sendmail.
var1='(
echo "From: name@xyz.com";
echo "To: name2@xyz.com";
echo "Subject: Test Subject";
echo "Content-Type: text/html";
echo "MIME-Version: 1.0";
echo "";
echo "<html><head><title>HTML E-mail</title></head>
<body><p>Test Body Message</p></body></html>";
)'
echo ${var1} | sendmail -t