parsing raw email in php

前端 未结 14 494
猫巷女王i
猫巷女王i 2020-12-23 20:50

I\'m looking for good/working/simple to use php code for parsing raw email into parts.

I\'ve written a couple of brute force solutions, but every time, one small cha

14条回答
  •  臣服心动
    2020-12-23 21:30

    You're probably not going to have much fun writing your own MIME parser. The reason you are finding "overdeveloped mail handling packages" is because MIME is a really complex set of rules/formats/encodings. MIME parts can be recursive, which is part of the fun. I think your best bet is to write the best MIME handler you can, parse a message, throw away everything that's not text/plain or text/html, and then force the command in the incoming string to be prefixed with COMMAND: or something similar so that you can find it in the muck. If you start with rules like that you have a decent chance of handling new providers, but you should be ready to tweak if a new provider comes along (or heck, if your current provider chooses to change their messaging architecture).

提交回复
热议问题