The problem is caused by multipart/alternative sections.
In that case the Content-type header contains the boundary name of the multipart section.
The code does not take into account that the multipart-section contains its own boundary for it subparts (that may or may not be different).
See example below:
Content-Type: multipart/related;
boundary="Message-Boundary-by-Mail-Sender-1467064509"
Return-Path: [email protected]
X-OriginalArrivalTime: 27 Jun 2016 21:55:11.0332 (UTC) FILETIME=[93D97240:01D1D0BE]
--Message-Boundary-by-Mail-Sender-1467064509
Content-Type: multipart/alternative;
boundary="Part-Message-Boundary-by-Mail-Sender-1467064509_2"
--Part-Message-Boundary-by-Mail-Sender-1467064509_2
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
In the example below the boundary is set to: Message-Boundary-by-Mail-Sender-1467064509
The multipart/alternative matches this boundary and then this is the only part being dealt with (reads to the end of the mail that closes this boundary).
What should be done is:
- in case of a multipart/alternative the new boundary is to be set (
Part-Message-Boundary-by-Mail-Sender-1467064509_2)
- with this new boundary the parts below should be parsed.
This seem correct as the code it dealing with this in a correct way ?
Tx