Re: 'Mail/mimeDecode': how can i identify attachments?

From: Date: Thu, 01 Apr 2010 11:16:38 +0000
Subject: Re: 'Mail/mimeDecode': how can i identify attachments?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-30430@lists.php.net to get a copy of this message
On 1 April 2010 11:30, Robert P. J. Day <rpjday@crashcourse.ca> wrote: > >  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:                                       �:¥>â,ÎXŸ.m´ï > ´http://twitter.com/rpjday > ======================================================================== > > -- > PEAR General Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > This should be what you need. http://pear.php.net/manual/en/package.mail.mail-mimedecode.decode.php Return value object - array $return->headers - an associative array of the headers. The keys of the array are the header names (lowercased) whilst the values are the header values (original case). If there are multiple headers with the same name (eg. Received: ) then the value is a numerically indexed array of each of the header values. If the parameter decode_headers is specified as TRUE, the headers will be decoded according to RFC 2047. string $return->ctype_primary - the first part of the content type (ie. before the forward slash). Eg. if the content type is multipart/mixed , ctype_primary would be "multipart" . string $return->ctype_secondary - the second part of the content type. Eg. If the content type is multipart/mixed , ctype_secondary would be "mixed" . -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling

« previous php.pear.general (#30430) next »