linux邮件file.log具有Content-Type:应用程序/八位字节流(Gmail中的非附件) [英] linux mail < file.log has Content-Type: application/octet-stream (a noname attachment in Gmail)

查看:196
本文介绍了linux邮件file.log具有Content-Type:应用程序/八位字节流(Gmail中的非附件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用

  mail -s这里是一个日志文件person@example.com< ; log / logfile.log 

哪些曾经通过标题:

 用户代理:传家宝邮件12.4 7/29/08 
MIME版本:1.0
内容类型:text / plain; charset = us-ascii
内容传输编码:7bit

但现在的文件是更长的时间我得到非附件,因为这样:

 用户代理:传家宝邮件12.4 7/29/08 
MIME版本:1.0
内容类型:应用程序/八位字节流
内容传输编码:base64

所以如果所有其他的失败,请查看手册 man mail ...

  NAME 
mailx - 发送和接收Internet邮件

概要
mailx [-BDdEFintv〜] [-s主题] [-a附件] [-c cc-addr] [-b bcc-addr] [-r from-addr] [-h hops]
[-A account] [-S variable [= value]] to-addr。 。 。

这些选项似乎很有用,所以我如何强制 Content-Type:文本/简单

解决方案

该手册页是开始的好地方!继续阅读,直到你到达 MIME TYPES 部分,并注意以下几点:


否则,如果文件名没有扩展名,则内容类型为
text / plain或application / octet-stream为
,第一个为文本或国际文本文件,第二个为任何文件包含除了换行符和水平制表符之外的格式化的char-
acters。


所以,如果你的消息包含格式化字符 (通常意味着控制字符)除了换行符和标签之外,它将自动被分类为 application / octet-stream 。我敢打赌,如果仔细查看数据,你会发现一些控制字符浮动。



你可以通过...解决这个问题。
$ b


  • 将日志文件作为附件(使用 -a )代替主消息正文,并设置将您的〜/ .mime.types 文件标识为 *。log 文件为text / plain。

  • 使用类似 tr 的过滤掉控制字符。

  • 使用另一个MUA,如 mutt 发送邮件。事实上,你可以自己制作一条信息,直接发送到 sendmail

     
    echo To:person@example.com
    echo From:you@example.com
    echo主题:一个日志文件
    echo
    cat logfile。 log
    )| sendmail -t



I've been using

 mail -s "here is a log file" "person@example.com" < log/logfile.log

Which used to come through with headers:

User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

But now the files are longer I'm getting noname attachments because with this:

User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64

So if all else fails, check the manual man mail ...

NAME
       mailx - send and receive Internet mail

SYNOPSIS
       mailx [-BDdEFintv~] [-s subject] [-a attachment ] [-c cc-addr] [-b bcc-addr] [-r from-addr] [-h hops]
              [-A account] [-S variable[=value]] to-addr . . .

None of these options seem useful so how can I force Content-Type: text/plain?

解决方案

The man page is a good place to start! Keep reading until you get to the MIME TYPES section, and pay close attention the following:

Otherwise, or if the filename has no extension, the content types text/plain or application/octet-stream are used, the first for text or international text files, the second for any file that contains formatting char‐ acters other than newlines and horizontal tabulators.

So, if your message contains "formatting characters" (which in general means control characters) other than newlines and tabs, it will automatically be classified as application/octet-stream. I bet that if you look closely at the data you'll find some control characters floating around.

You can work around this by...

  • Including the log file as an attachment (using -a) instead of the main message body, and set up your ~/.mime.types file to identify *.log files as text/plain.
  • Filter out control characters using something like tr.
  • Use another MUA such as mutt to send the mail. In fact, you could just craft a message yourself and send it directly to sendmail:

    (
      echo To: person@example.com
      echo From: you@example.com
      echo Subject: a logfile
      echo
      cat logfile.log
    ) | sendmail -t
    

这篇关于linux邮件file.log具有Content-Type:应用程序/八位字节流(Gmail中的非附件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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