附录 B. 从 RFC 822 头部字段生成 SMTP 命令 (Generating SMTP Commands from RFC 822 Header Fields)
本附录提供从 RFC 5322 (以前的 RFC 822) 消息头部字段生成 SMTP envelope 命令 (MAIL FROM 和 RCPT TO) 的指导.
Envelope 地址与 Header 地址
SMTP Envelope: MAIL FROM 和 RCPT TO 命令中使用的地址
Message Headers: 出现在 From:, To:, Cc:, Bcc: 字段中的地址
重要: Envelope 地址和 header 地址可能不同.
生成 MAIL FROM
reverse-path (MAIL FROM) 通常应从以下来源派生:
- Return-Path header (如果存在且可信)
- Sender header (如果存在)
- From header (fallback)
对于 bounce 消息, 使用 null reverse-path: MAIL FROM:<>
生成 RCPT TO
接收者应从以下字段收集:
- To: header
- Cc: header
- Bcc: header (随后从消息中移除)
- Resent-To:, Resent-Cc:, Resent-Bcc: (用于 resent messages)
示例
Message Headers:
From: [email protected]
To: [email protected]
Cc: [email protected]
Bcc: [email protected]
Subject: Meeting tomorrow
SMTP Commands:
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
传输的 Message Headers (已移除 BCC):
From: [email protected]
To: [email protected]
Cc: [email protected]
Subject: Meeting tomorrow
特殊情况
分发列表 (Distribution Lists)
发送到邮件列表时, RCPT TO 可能不同于可见的 To:/Cc: 头部:
MAIL FROM:<[email protected]>
RCPT TO:<[email protected]>
RCPT TO:<[email protected]>
...
Headers show:
To: [email protected]
转发 (Forwarding)
转发时, 原始 envelope 可能与头部不同:
Original: alice -> bob
Forward: bob -> charlie
MAIL FROM:<[email protected]> (original sender)
RCPT TO:<[email protected]> (new recipient)