哪些电子邮件标头字段可以包含参数?

发布于 2024-12-04 02:54:35 字数 807 浏览 3 评论 0原文

我试图找出电子邮件解析库中可以有哪些通用子例程。

我知道两个经常带有参数的 MIME 字段:(

Content-Type: application/x-stuff;
 title*=us-ascii'en-us'This%20is%20%2A%2A%2Afun%2A%2A%2A

示例来自 https://www.rfc- editor.org/rfc/rfc2231

Content-Disposition: attachment; filename=genome.jpeg;
 modification-date="Wed, 12 Feb 1997 16:29:51 -0500";

(示例来自 https://www.rfc-editor.org/rfc/rfc2183

它们是唯一的 - 或者这是一个通用机制? https://www.rfc-editor.org/rfc/rfc822仅谈论“结构化”字段 - 上面的字段肯定是“结构化”的,但 rfc822 中的示例是关于地址字段的 - 这是一个不同的结构 - 列表地址。

I am trying to find out what universal subroutines can I have in an email parsing library.

I know of two MIME fields that often take parameters:

Content-Type: application/x-stuff;
 title*=us-ascii'en-us'This%20is%20%2A%2A%2Afun%2A%2A%2A

(example from https://www.rfc-editor.org/rfc/rfc2231)

and

Content-Disposition: attachment; filename=genome.jpeg;
 modification-date="Wed, 12 Feb 1997 16:29:51 -0500";

(example from https://www.rfc-editor.org/rfc/rfc2183)

Are they the only ones - or is this an universal mechanism? https://www.rfc-editor.org/rfc/rfc822 only talks about 'structured' fields - the fields above are 'structured' for sure, but the example in rfc822 is about an address field - which is a different structure - list of addresses.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一影成城 2024-12-11 02:54:35

据我所知,电子邮件中还有两个 MIME 字段:

MIME-Version: 1.0

一个没有参数,

Content-Transfer-Encoding: ...

一个也没有。

没有通用的“MIME头字段参数规则”,只需查找每个头字段的标准定义即可。

(编辑:)添加原始问题后,您当然可以使用通用子例程。请注意,电子邮件标头解析是一项重要的任务(参见 RFC 2822)。我想到了这些通用子例程:

  • 删除标题字段中的注释(用括号表示)。
  • 处理选项卡缩进行(连续行)
  • 解析 RFC822 日期/时间(艰巨的任务:)
  • 处理引用
  • 解析电子邮件地址(不同形式)
  • 处理字符编码(MIME 标头编码)

但是,所有这些当然都存在于许多开源库中。

There are two more MIME fields in email as far as I know:

MIME-Version: 1.0

which has no parameters, and

Content-Transfer-Encoding: ...

has none, either.

There is no general "MIME header field parameter rule", just look up the standard definition for each header field.

(EDIT:) After your additions to the original question, you can of course use universal subroutines. Be warned that email heaader parsing is a nontrivial task (cf. RFC 2822). These universal subroutines come into my mind:

  • Remove comments in the header fields (denoted by parenthesis).
  • Handle tab indent lines (continuation lines)
  • Parse RFC822 date/times (huge task :)
  • Handle quotation
  • Parse email addresses (different forms)
  • Handle character encoding (MIME header encoding)

However, all this exists in many open source libraries of course.

甜警司 2024-12-11 02:54:35

Received: 标头通常是结构化的,尽管规范相当模糊并且没有认真的标准化工作。最接近事实上的标准的是 Sendmail,Postfix 或多或少地模仿了它。 DKIM 签名的结构非常巧妙。 SpamAssassin插入的ad hoc header有一个结构;它告诉您为什么邮件被归类为垃圾邮件。还有很多,但这应该给你一些可以开始咀嚼的东西。此处的示例均未使用 Mime Content-xxx 语法。

The Received: header is typically structured, although the spec is rather vague and there is no serious standardization effort. The closest thing resembling a de facto standard is Sendmail, which is mimicked more or less closely by Postfix. The DKIM signature is structured, in a fairly clever way. The ad hoc header inserted by SpamAssassin has a structure; it tells you why a message was classified as spam. There are oodles more, but this should give you something to start chewing. None of the examples here use the Mime Content-xxx syntax.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文