a couple more questions about mimeDecode, if i might
| From: | Robert P. J. Day | Date: | Mon, 05 Apr 2010 19:54:07 +0000 |
| Subject: | a couple more questions about mimeDecode, if i might | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-30443@lists.php.net to get a copy of this message | ||
(i apologize for seeming to monopolize this list for that one
package. i am making progress -- at least my questions are getting
more intelligent. right? right?)
i'm finally getting to the part of my project that's going to be the
trickiest -- using mimeDecode to get to either the simple text of an
email message if it's just text, or to the attachment if it's got an
attachment. (technically, i want to decode either SMS or MMS text
messages as i get them. and the more i look at them, the uglier this
gets.)
i've been practising sending simple emails to a test server of mine,
where email redirection simply passes the raw source of each email
into a PHP script, at which point i can have my way with it. i
choose, unsurprisingly, to run it through mimeDecode, and it's at this
point where there might be all sorts of possibilities for how i
*interpret* the results. (as in, the mime decoding works fine -- it's
examining the results that might be ambiguous.)
for the few tests i've run, with simple text messages, the resulting
mimedecoded object seems to represent those text messages with
$obj->ctype_primary = text
$obj->ctype_secondary = plain
and the message body can be found at
$obj->body
seems straightforward enough -- if an email comes in with those
content-type values, i simply read the body. but from what i've seen
elsewhere, depending on the sending domain, some sending mailers will
tack on all kinds of crap like, "Sent by <carrier>" or some such, over
which i have no control, of course. so in cases like that, it's just
a matter of getting a large enough sample of messages and seeing what
different carriers do to their text messages.
email with attachments (multipart or MMS messages) are, as i
understand it, even worse. from what i've heard, there could be
different standards for how different carriers handle attachments.
and *some* carriers even send simple text as multipart messages, as
they insist on adding an HTML version of each text message. grrrrrr.
so, the question: is there some sort of (RFC?) standard that
dictates at least a minimal set of rules that will help me interpret
the mime-decoded email? even if some carriers have the freedom to do
really weird stuff with how they construct an email, is there at least
a fundamental standard they *must* follow, to help me with the
interpretation?
rday
p.s. what would, of course, be awesome is if there was a way to get
various carriers to send me sample emails. does such a thing even
exist?
--
========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA
Linux Consulting, Training and Kernel Pedantry.
Web page: http://crashcourse.ca
Twitter: http://twitter.com/rpjday
========================================================================