Multipart parser

I need to parse a multipart body of an email. I searched for parsers, and I could not find anything.

There is Plus.Parsers.MULTIPART, but it works on Plus.Conn struct, and I don’t have one. I only have a string of raw body.

I couldn’t find a way to use that plus parser.

Is there anything that could help me? I mean besides writing a parser myself, I’m already working on that.

The goal is to parse body of an email sent through SMTP, but I suppose normal HTTP multipart parsers should work too.

The plug parser does not need a conn for it’s actual parsing as far as I can see. It just pulls the body and some options from the conn. Maybe you can pull out / extract the multipart parsing.

Or just create a mock Plug.Conn struct and put your data where it needs to be. I’ve created a lot of fake Plug.Conn struct instances just to use some plug API’s. I wish it pulled more of it’s stuff out into libraries, I use the ‘conn’ style of pipeline coding in a lot of non-web areas… We need a Generic non-web Plug library. ^.^

2 Likes