And while I've been trying to regex them out I simply haven't been able to. The fact that standard e-mails should end their lines in

\n

but some

do in \r\n

combined with the nesting thing is too much for me to handle.

There's a library in PHPClasses that splits e-mails into MIME parts (along with a bunch of other things), written by some Manuel Lemos guy who clearly knew what he was doing since it's really efficient and returns nicely formatted and parsed, but it doesn't cut it for me.

The library itself consists of +2500 lines of unintelligible gibberish I can't make any sense of (it being written in 3 different camelCases and using assorted indentation styles along with different types of ifs (like

if():

and

if()

and

if(){}

and loops like

for(;;)

,

for(){}

and

for():

does not make it much simpler)

Could anyone please give me a hand here?

Thank you very much!

-- Edited to add

Following Sjoern's advice I started building a solution to my own question (thanks!!). I'm still open to more suggestions though; surely there's better ways of doing it)