在shell脚本中的电子邮件中嵌入2个HTML表(一个接一个)

4si2a6ki  于 2023-03-09  发布在  Shell
关注(0)|答案(1)|浏览(188)

我必须打印2个表的数据(这是sql查询的输出)一个接一个,并在shell的电子邮件中发送(使用sendemail实用程序)。
我有如下的html代码

echo "MIME-Version: 1.0"
#echo "Content-Type: multipart/alternative; " 
echo "Content-Type: multipart/mixed;"
echo ' boundary="some.unique.value.ABC123/server.xyz.com"' 
echo "Subject: "
echo ""
echo "This is a MIME-encapsulated message"
echo ""
echo "--some.unique.value.ABC123/server.xyz.com"
echo "Content-Type: text/html"
echo ""
echo "<html> <head> <style>table, th, td {  border: 0.5px solid black;}</style><title>Some Title</title></head><body><table style=\"width:100%\" >"
echo "<tr><th>Col1</th><th>Col2/th><th>Col3</th><th>Col4</th></tr>"
cat  mailbody
echo " "
echo "</body></html>"
echo  "Some text here"
echo " "
echo "<html> <head> <style>table, th, td {  border: 0.5px solid black;}</style><title>Some Title</title></head><body><table style=\"width:100%\" >"
echo "<tr><th>Col1</th><th>Col2/th><th>Col3</th><th>Col4</th></tr>"
cat  mailbody2
echo " "
echo "</body></html>"

输出应类似于

但实际上输出是不同的

我怎样才能达到预期的产出?

km0tfn4u

km0tfn4u1#

答案就在这篇文章中-New lines (\r\n) are not working in email body
我的问题在原来的职位是在这里

echo "</body></html>"
echo  "Some text here"
echo " "

解决方案是:

echo "</body></html><BR><BR />"
echo  "Some text here<p>"
echo "<BR><BR />"

相关问题