【发布时间】:2011-10-17 08:49:27
【问题描述】:
我在 Perl 中使用 MIME::Entity 模块来创建 MIME 消息。一些标头似乎编码正常,而其他标头似乎有折叠问题。
代码:
use strict;
use Encode;
use MIME::Entity;
my %build_params = (
'Charset' => 'UTF-8',
'From' => encode('MIME-Header', 'Fantasy Email <vujerldujhgurtelhwgutrwhgunwlhvulhgvnuwlhvuwlnhvgnulwh@gmail.com>'),
'Subject' => encode('MIME-Header', "A very long subject that will span on multiple lines in the headers, with a leading sp\
ace at the beginning of each new line."),
'Type' => 'multipart/alternative',
);
my $top = MIME::Entity->build(%build_params);
$top->print_header();
输出:
Content-Type: multipart/alternative;
boundary="----------=_1312196104-11708-0";
charset="UTF-8"
Content-Transfer-Encoding: binary
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Subject: A very long subject that will span on multiple lines in the
headers, with a leading space at the beginning of each new line.
From: Fantasy Email
<vujerldujhgurtelhwgutrwhgunwlhvulhgvnuwlhvuwlnhvgnulwh@gmail .com>
Subject 似乎被正确拆分为多行。 From 没有,在com 之前留了一个空格,但换行符消失了。
这是标准行为还是我在 MIME::Entity 中发现了错误?
【问题讨论】:
-
对我来说似乎是一个错误。主要是
.com之前的空格。此外,如果您完全复制它产生的内容,似乎在headers,之后添加了一个新空格。 -
嗯,逗号后面的双空格是对的。这显然是一个错误。
-
另请注意,添加的空格可能在两个标题中的位置相同,因此可能是
MIME::Entity上的拆分表达式中的错误。
标签: perl email encoding header mime