Mails from Sendmail are ignoring line endings, when I try to send email with attachment. I have tried to specify the font in the html but line endings are still ignored. I also tried unix2dos, still no luck.
#!/usr/bin/ksh
###Send Email
MAILTO=`cat mail2.list | tr -s '\n' ','`
SUBJECT="bla bla bla"
SENDER=$(nawk -F= 'tolower($0) ~ /emailsender/{print $2;exit;}' param.txt)
ATTACH="filename.txt"
(
echo "Subject: $SUBJECT"
echo "From: $SENDER"
echo "To: $MAILTO"
echo "MIME-Version: 1.0"
echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
echo
echo '---q1w2e3r4t5'
echo "Content-Type: text/html"
echo "Content-Disposition: inline"
echo '<HTML><BODY><PRE>'
cat report.txt
echo '</PRE></BODY></HTML>'
echo '---q1w2e3r4t5'
echo 'Content-Type: application; name="'$(basename $ATTACH)'"'
echo "Content-Transfer-Encoding: uuencode"
echo 'Content-Disposition: attachment; filename="'$(basename $ATTACH)'"'
uuencode $ATTACH $(basename $ATTACH)
echo '---q1w2e3r4t5--'
) | /usr/sbin/sendmail -t
I can send with monospace font and all lines ending preserved using this (without attachment):
#!/usr/bin/ksh
###Send Email
MAILTO=`cat mail2.list | tr -s '\n' ','`
SUBJECT="bla bla bla"
SENDER=$(nawk -F= 'tolower($0) ~ /emailsender/{print $2;exit;}' param.txt)
(
echo "Subject: $SUBJECT"
echo "From: $SENDER"
echo "To: $MAILTO"
echo "MIME-Version: 1.0"
echo "Content-Type: text/html"
echo "Content-Disposition: inline"
echo '<HTML><BODY><PRE>'
cat report.txt
echo '</PRE></BODY></HTML>'
) | /usr/sbin/sendmail -t