'Mail/mimeDecode': how can i identify attachments?
| From: | Robert P. J. Day | Date: | Thu, 01 Apr 2010 10:30:57 +0000 |
| Subject: | 'Mail/mimeDecode': how can i identify attachments? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-30429@lists.php.net to get a copy of this message | ||
what sounds like an easy question but if i run incoming email
messages thru mimeDecode, how can i reliably distinguish between
messages that have non-text attachments (pic, audio, video) and those
that don't?
more specifically, i have a PHP script that's being fed incoming
text messages, some of which (SMS) have a simple, short text body,
while the others (MMS) will have some sort of attachment, and i want
to quickly distinguish between the two.
after mime decoding the incoming message, i figured i could just
look for the existence of a 'parts' key in the message array, assuming
that attachments would be represented by a multi-part message. but
apparently, there are carrier gateways out there that will construct
multi-part messages even for simple text messages.
so i'm sure there are numerous ways to do this but is there a
canonical way to check if a mime-decoded email has a non-text
attachment? thanks.
rday
--
========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA
Linux Consulting, Training and Kernel Pedantry.
Web page: http://crashcourse.ca
Twitter: http://twitter.com/rpjday
========================================================================