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

Correct way to work with multiparts #192

Open
lorenzo80 opened this issue May 1, 2022 · 1 comment
Open

Correct way to work with multiparts #192

lorenzo80 opened this issue May 1, 2022 · 1 comment

Comments

@lorenzo80
Copy link

Hi,
we are using version 2.2.1 to parse our incoming email.

No unsolvable issue so far, until we received an automatic email from our email system about an undeliverable message.
Trying to parse it proved impossible, because a big chunk of the message doesn't get retrieved by parse().
A quick troubleshooting revealed that the message was a multipart.

The problem is: I never saw one before, and there is practically no indications about how to handle them that ?ve been able to find.
I can retrieve with getAllParts() but after that I'm at a loss.

Example
Undelivered Mail Returned to Sender.txt

The message is attached, I had to redact the addresses / domains / subject per our policy but the rest is intact.
I can deliver it to you privately, if needed.
I tried to do a supposedly easy task -> retrieve the string "ORIGINAL SUBJECT".
After three hours of testing with getAllParts(), getPart(), Get Child() I'm still at the starting point.

I'm pretty sure I tunneled and I might be missing something easy and obvious.
Could you please point me toward some documentation or post the necessary code?

Thanks in advance!

@zbateson
Copy link
Owner

zbateson commented May 5, 2022

Hi @lorenzo80 --

The 'headers' of the undelivered email are a separate 'email object', they're not part of the current one if that makes sense. It's an attached part that happens to be an email.

Basically, if you pass the body of that part to the parser you'll get a separate email object, e.g. $returned = $mmp->parse($child->getContentStream()); echo $returned->getHeaderValue('subject'); should do the trick...

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