使用 bash shell 脚本的 HTML 格式电子邮件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12702840/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 03:26:56  来源:igfitidea点击:

HTML formatted email using bash shell script

bashshellmailx

提问by arsenal

This is my below script which is working fine as it send only plain text email.

这是我下面的脚本,它运行良好,因为它只发送纯文本电子邮件。

So My question is- How can I modify my below script to send this as an HTML formatted email? I want to show the text color of this expression (echo "100*$TEST2/$TEST1" | bc -l)as REDin an email and that can be done only in HTML formatted emails. So that is the reason I was thinking to send an email in HTML formatted way. Any suggestions will be of great help.

所以我的问题是 - 如何修改我的以下脚本以将其作为 HTML 格式的电子邮件发送?我想表明,该表达的文本颜色(echo "100*$TEST2/$TEST1" | bc -l)RED在一封电子邮件中,并且可以做到只在HTML格式的电子邮件。所以这就是我想以 HTML 格式发送电子邮件的原因。任何建议都会有很大帮助。

#!/bin/bash

TEN_DAYS="3793274 230667"

TEST1=`echo $TEN_DAYS | awk '{print }'`
echo $TEST1

TEST2=`echo $TEN_DAYS | awk '{print }'`
echo $TEST2

mailx -s "Report" -r [email protected] [email protected] <<EOF

Error  Percentage: `(echo "100*$TEST2/$TEST1" | bc -l)`

EOF

采纳答案by P?r S?rn?