【发布时间】:2015-05-11 08:35:37
【问题描述】:
我编写了一个在邮件正文中创建 html 表的脚本,我想使用邮件命令和 uuencode 发送一个文件/zip 作为附件,但不知何故它在 bash 脚本中不起作用,但在控制台中起作用。
mailbody="<html><table><th><tr><td>Name</td><td>Age</td></tr></th><tr><td>\
ABC</td><td>25</td></tr></table></html>"
echo $mailbody>>mailer.txt
#assume i have test.txt or test.zip which i need as attachment in mail
#i tried below with html part as body
uuencode test.txt test.txt|mail -s "Test mail\nContent-Type: text/html" "xyz.com" <mailer.txt
这会发送邮件,邮件正文显示 html 表格但附件丢失。
uuencode test.txt test.txt|mail -s "Test mail" "xyz.com" properly send mail with test.txt as attachment but a plain mail , no html
提前致谢
【问题讨论】:
-
如果您不能使用
mutt或 MetaMail,请查看 stackoverflow.com/a/902628/41747 以获得更好的选择。