使用uuen code时,从bash脚本命令邮件不发送附件,邮件正文是HTML文件 [英] mail command from bash script not sending attachment when using uuencode , mail body is html file

查看:157
本文介绍了使用uuen code时,从bash脚本命令邮件不发送附件,邮件正文是HTML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个脚本,这使得HTML表格在邮件正文,我想用mail命令和uuen code,但不知它不是bash脚本内部组件发送一个文件/ ZIP作为附件但是从控制台的作品。

<$p$p><$c$c>mailbody=\"<html><table><th><tr><td>Name</td><td>Age</td></tr></th><tr><td>\\
           ABC&LT; / TD&GT;&LT; TD&GT; 25℃; / TD&GT;&LT; / TR&GT;&LT; /表&gt;&LT; / HTML&gt;中
回声$ mailbody&GT;&GT; mailer.txt
#assume我已经test.txt和test.zip,我需要在邮件的附件
#我与HTML一部分身体下面试着
uuen code的test.txt test.txt的|邮件-s测试邮件\\ nContent类型:text / html的xyz.com&LT; mailer.txt

这与发送邮件正文邮件显示HTML表格,但附件丢失。

  uuen code的test.txt test.txt的|邮件-s测试邮件,xyz.com用正确的test.txt发送邮件作为附件,但一个普通的邮件,没有HTML

在此先感谢


解决方案

这是一个相当普遍的问题,但它一般难于回答,因为没有一个标准的邮件命令。一些支持你想什么;大多数人没有。

看到你遇到了问题,可能是你属于哪个不支持MIME,但检查其手册页有前途的选项组中。

传统,电子邮件是纯文本,7位US-ASCII,并没有这样的事情附件。早在20世纪80年代的某个时候进入上世纪90年代,如果你想派人一个文件,你嵌入 uuen code 官样文章的板坯到电子邮件消息的文本,并希望收件人将知道该怎么用它做。

输入MIME。现代电子邮件是一个结构的存在,其中每个消息具有一个或多个MIME部分,每一个内容类型和编码。 扣押没有正确定义良好的,但通常,不能内嵌显示一个MIME部分显示由您的电子邮件客户端可点击的链接。

为了与在现代世界中的附件发送HTML邮件,您需要发送消息的MIME感知电子邮件客户端。看起来像你的邮件不符合。一个共同的解决办法(几乎如此普遍,是一个事实上的标准)是安装和使用代替,但有可能是,如果你是在一个合理的现代平台更轻的替代品

I have written a script which makes a html table in mail body , I want to send a file/zip as attachment using mail command and uuencode but somehow its not working inside bash script but works from console .

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

this sends mail with mail body showing html Table but attachment is missing .

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

thanks in advance

解决方案

This is a fairly common question but it is hard to answer generally because there is no one standard mail command. Some support what you are trying; most don't.

Seeing as you are having trouble, probably yours belongs to the group which doesn't support MIME, but do check its manual page for promising options.

Traditionally, e-mail is text only, 7-bit US-ASCII, and there is no such thing as "attachments". Back in the 1980s and sometime into the 1990s, if you wanted to send somebody a file, you embedded a slab of uuencode gobbledygook into the text of the email message, and hoped the recipient would know what to do with it.

Enter MIME. The modern email is a structured being, where each message has one or multiple MIME parts, each with a content type and an encoding. An "attachment" isn't properly well-defined, but commonly, a MIME part which cannot be displayed inline is shown as a clickable link by your email client.

In order to send HTML messages with attachments in the modern world, you need a MIME-aware mail client for sending messages. Looks like your mail doesn't qualify. A common workaround (nearly so common as to be a de facto standard) is to install and use mutt instead, but there are probably lighter alternatives if you are on a reasonably modern platform.

这篇关于使用uuen code时,从bash脚本命令邮件不发送附件,邮件正文是HTML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆