Reputation: 995
I have a Scenario where I am bit struggling to implement this simple change Need to print Body text in proper format
Lets assume I have parameters defined :
EmailSubjectDemo="New Message : `date`"
EmailbodyDemo="Hi Bro How \\nare \\nyou"
EmailToDemo="[email protected],[email protected]"
EmailFromDemo="[email protected],[email protected]"
Now my Sendmail code :
(
echo "From : $EmailFromDemo"
echo "To : $EmailToDemo"
echo "MIME-Version: 1.0"
echo "Subject: $EmailSubjectDemo"
echo "Content-Type: text\html"
echo -e "$EmailbodyDemo"
) sendmail -t
This echo -e "$EmailbodyDemo"
is not printing data in proper new line format
even i tried with printf $EmailbodyDemo
but no luck
Expected output of Email Body :
Hi Bro How
are you
Note : This -e and printf does not work at my end
I am not allowed to create a separate text file and call it in sendmail
code like cat file.txt
Hi Bro How
are you
Any other approach is appreciated
Upvotes: 1
Views: 597
Reputation: 995
This approach worked for me
Writing the Body text content within html tags
#Pre-Defined parameters
EmailSubjectDemo="New Message : `date`"
EmailbodyDemo="<html> <body> Hi Bro How <br> are <br> you </body> </html>"
EmailToDemo="[email protected],[email protected]"
EmailFromDemo="[email protected],[email protected]"
#Sending mail
(
echo "From : $EmailFromDemo"
echo "To : $EmailToDemo"
echo "MIME-Version: 1.0"
echo "Subject: $EmailSubjectDemo"
echo "Content-Type: text\html"
echo -e "$EmailbodyDemo"
) sendmail -t
Upvotes: 1