2012-05-07 31 views
0

我正在寻找一种方法来发送附加文件bash的HTML电子邮件。 我试过下面这一行,但它不能100%正常工作。下面的线发送的HTML电子邮件,但没有附加的文件:Bash:用附件发送HTML文件?

(cat body.html ; uuencode in-attachfile.txt out-attachfile.txt) | mail -s "$(echo -e "my subject\nContent-Type: text/html")" [email protected] 

如果我删除Content-Type: text/html以表明这是一个HTML电子邮件,则附件的工作原理:

(cat body.html ; uuencode in-attachfile.txt out-attachfile.txt) | mail -s "$(echo -e "my subject")" [email protected] 

怎样才可以有都?

谢谢

回答

2

试试这个:

(cat body.html; uuencode in-attachfile.txt out-attachfile.txt) | mail -s "my subject" -a "Content-Type: text/html" [email protected] 

您可能需要发送邮件使用MIME附件(通过狗,例如)。有关更多信息,请参阅this

+0

我的'邮件'没有'-a'选项...我正在运行centOS。 – thedp

+1

你可以使用sendmail吗?另外,我认为可以使用多部分MIME类型在HTML中嵌入文档。尝试查看原始文档,该文档包含您需要构建的所有功能并从此构建。祝你好运。 – shellter

+0

@shellter您可以给我一个sendmail MIME的例子。谢谢。 – thedp