I need to send contents of a file in an email and add some html note at the beginning and ending of the file. I have used "sendmail" for the purpose, however when I receive the email I do not see the line breaks in outlook causing the trouble. I have tried using the "mail" command but not sure how to add HTML notes to it. Here is the snippet I have:
open(my $sendmail,"|/usr/sbin/sendmail -t"); print $sendmail "From: linux\@test.com\n"; print $sendmail "To: kris\@test.com\n"; print $sendmail "Content-Type: text/html\n"; print $sendmail "Subject: My Test\n"; print $sendmail "\n"; my $Header = << 'END'; <html> <head> <h3><font color="red">For test</font></h3> </head> <body> <h3><font color="red">For test</font></h3> <br/> </body> </html> END print $sendmail $Header; print $sendmail "<br>Ran for time: \n"; my $alert3 = `/bin/cat /home/kris/test.txt`; print $sendmail $alert3; close($sendmail);
while this works just fine to send the email, the contents of the file in "alert3" come in one single line vs several when you do cat. I also changed line break options in outlook with no luck. Is there any better way to handle these situations?