我这里有一个示例脚本,我想在文本中加粗单词 BOLD 并通过电子邮件发送。尝试了几种方法但似乎不起作用。
BODY="Hello. I want to BOLD this"
{
echo "From: [email protected]"
echo "To: [email protected]"
echo "Subject: Texting"
echo "X-Mailer: htmlmail" $VERSION
echo "Mime-Version: 1.0"
echo "Content-Type: text/html; charset=US-ASCII"
print "<html><FONT COLOR=BLACK FACE="Geneva,Arial"SIZE=8><body>${BODY} </body>"
print "<html><FONT COLOR=BLACK FACE="Geneva,Arial"SIZE=10> ${BODY} </html>"
} | /usr/sbin/sendmail -t
答案1
- 您需要在电子邮件标题和正文之间添加一个空行。
- 您试图将双引号错误地放入双引号字符串中。
尝试这个:
/usr/sbin/sendmail -t <<END_EMAIL
From: [email protected]
To: [email protected]
Subject: Texting
X-Mailer: htmlmail $version
Mime-Version: 1.0
Content-Type: text/html; charset=US-ASCII
<html><body><p><b>${BODY}</b></p></body></html>
END_EMAIL
答案2
这些变量可能有用
reset_colour=$( tput sgr0)
bold=$( tput bold)
black=$( tput setaf 0)
red=$( tput setaf 1)
green=$( tput setaf 2)
yellow=$( tput setaf 3)
blue=$( tput setaf 4)
magenta=$( tput setaf 5)
cyan=$( tput setaf 6)
white=$( tput setaf 7)
default_colour=$( tput setaf 9)