对于这两种情况,我如何在 Linux 中为电子邮件设置颜色编码?我查看了其他堆栈,它们正在构建函数,是否有任何简单的方法来执行此操作(无需 HTML)编码?
1) Job running... text in green color?
echo -e "Job running..." | mail -s "Job running..."
2) Job failing... text in red color?
echo -e "Job failing..." | mail -s "Job failing..."
Tries. echo gives on the front end, but doesn't send the color in email.
echo -e '\033[0;32m'"\033[1mJob running...\033[0m" | mail -s "Job running..." test@example.com
谢谢!
最佳答案
使用 ANSI 转义序列(如果使用 bash!):
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
echo -e "${GREEN}Job running...${NC}" | mail -s "Job running..."
echo -e "${RED}Job failing...${NC}" | mail -s "Job failing..."
不使用 HTML 为收件人着色邮件是不可能的。如果您希望在生成的邮件中使用颜色,请使用 HTML 格式。
关于linux - 如何在 Linux 中为电子邮件添加颜色编码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35015615/