Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parts_add() on multipart/mixed results in two multipart/mixed #17

Open
futon88 opened this issue Aug 25, 2014 · 1 comment
Open

parts_add() on multipart/mixed results in two multipart/mixed #17

futon88 opened this issue Aug 25, 2014 · 1 comment

Comments

@futon88
Copy link

futon88 commented Aug 25, 2014

It's not clear whether this is an issue, or not, but it certainly caught me by surprise:

my $mixed = Email::MIME->create(
    attributes => {content_type => "multipart/mixed"},
    header_str => [Subject => "Subject"],
);
my $related = Email::MIME->create(
    attributes => {content_type => "multipart/related"},
);
$mixed->parts_add([$related]);
print $mixed->as_string;

Results in:

Subject: Subject
Date: Mon, 25 Aug 2014 10:13:30 -0400
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="1408976010.DFC040.11480"


--1408976010.DFC040.11480
Subject: Subject
Date: Mon, 25 Aug 2014 10:13:30 -0400
MIME-Version: 1.0
Content-Type: multipart/mixed


--1408976010.DFC040.11480
Date: Mon, 25 Aug 2014 10:13:30 -0400
MIME-Version: 1.0
Content-Type: multipart/related

--1408976010.DFC040.11480--

My expectation is that doing a parts_add() with a single new part would be equivalent to parts_set() with the same part, which results in:

Subject: Subject
Date: Mon, 25 Aug 2014 10:15:15 -0400
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="1408976115.Be2FCB00.11602"


--1408976115.Be2FCB00.11602
Date: Mon, 25 Aug 2014 10:15:15 -0400
MIME-Version: 1.0
Content-Type: multipart/related


--1408976115.Be2FCB00.11602--

Anecdotally, these mixed-within-mixed messages appear to render completely blank in Windows Live Mail.

@bbkr
Copy link

bbkr commented Oct 31, 2015

The workaround I found is to use parts in constructor.

my $related = Email::MIME->create(
    attributes => {content_type => "multipart/related"},
);

my $mixed = Email::MIME->create(
    attributes => {content_type => "multipart/mixed"},
    header_str => [Subject => "Subject"],
    parts => [$related]
);

print $mixed->as_string;

Result:

Subject: Subject
Date: Sat, 31 Oct 2015 09:39:51 +0100
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="14462807910.dDd8E.69946"
Content-Transfer-Encoding: 7bit


--14462807910.dDd8E.69946
Date: Sat, 31 Oct 2015 09:39:51 +0100
MIME-Version: 1.0
Content-Type: multipart/related


--14462807910.dDd8E.69946--

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants