On Jan 8, 2008, at 4:34 AM, Alexandru Stanoi wrote:

> Dave Fischetti wrote:
>> On Jan 7, 2008, at 10:14 AM, Alexandru Stanoi wrote:
>>> Dave Fischetti wrote:
>>>> I have all mail coming in and being parsed also redirected to   
>>>> another email account so I see everything that comes in as I  
>>>> test  (since the parsed deletes things immediately). It seems  
>>>> that these  files coming in are images. in one case the file was  
>>>> named the same  in both cases but it wasn't picked up by the  
>>>> parser. The only other  attachement in that email was some text  
>>>> file that was blank. so it  should have seen the image. Maybe it  
>>>> was just a hiccup. But then  another one recently wasn't picked  
>>>> up. This one is from a different  phone carrier:
>>>> Content-Type: image/jpeg;  
>>>> name=m_000c8e00983658a5839ec75edd2031a4.jpg
>>>> Content-Transfer-Encoding: base64
>>>> Content-Location:media1.jpeg
>>>> Content-ID: <136>
>>>> /9j/4AAQSkZJRgABAQEAYABgAAD/  
>>>> 2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0a
>>>> HBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/  
>>>> 2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIy
>>>> MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/  
>>>> wAARCADiAKoDASIA
>>>> AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/  
>>>> 8QAtRAAAgEDAwIEAwUFBAQA
>>>> AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3
>>>> ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm
>>>> p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4  
>>>> +Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA
>>>> AwE... ... ... ... <snip>
>>>> The attachment in my mirrored mail shows up fine. The filename  
>>>> is  "m_000c8e00983658a5839ec75edd2031a4.jpg"
>>>> There are 5 other attachments in that email. All are gif files  
>>>> and  should be skipped by my code I believe. I actually went back  
>>>> to a  few other emails from this carrier and their emails also  
>>>> have jpg  images that are missed by the parser.
>>>> Do you have any other suggestions as to what might be causing  
>>>> this.  DO you want me to send the full source for an email that  
>>>> had a  missed image? Would more of my code help?
>>> It would be helpful to have the full mail, and the code which   
>>> process it.
>>>
>>> -- 
>>> Alexandru Stanoi
>>> eZ Components System Developer
>>> eZ Systems | http://ez.no
>> Here is a good portion of my code. I cut out some stuff that  
>> shouldn't  be needed. Thanks again.
>> set_include_path( "/usr/include/php/ezcomponents-2007.1.1:" .   
>> ini_get( "include_path" )  );
>> // Create a new POP3 transport object by specifying the server name
>> $pop3 = new ezcMailPop3Transport( "mail.myDomain.com" );
>> // Authenticate to the POP3 server
>> $pop3->authenticate( "[EMAIL PROTECTED]", "mypass" );
>> // Fetch all messages on the server then delete
>> $set = $pop3->fetchAll(true);
>> // Create a new mail parser object
>> $parser = new ezcMailParser();
>> ezcMailCharsetConverter::setConvertMethod( array( 'myConverter',   
>> 'convertToUTF8IconvNoNotices' ) );
>> // Parse the set of messages retrieved from the server
>> $mails = $parser->parseMail( $set );
>> //print_r($mail);
>> foreach ( $mails as $mail )
>> {
>>      $from = formatAddress( $mail->from );
>>      $to = formatToAddress( $mail->to );
>>      // hack for sprint users
>>      if ($from == "") $from = formatAddress( $mail->returnPath ); //   
>> sometimes from is blank from some carriers
>>      if ($to == "") $to = substr($mail->headers['Delivered-To'],2); //   
>> sometimes to is blank from some carriers
>>      // end hack
>>      
>>      $subject = $mail->subject;
>>      $mailTimeStamp = $mail->timestamp;
>>      if($mailTimeStamp == "" || is_null($mailTimeStamp)) $mailTimeStamp  
>> =  time();
>>      $date = calculateTimeZone(gmdate("Y-m-d H:i:s",  
>> $mailTimeStamp),"EST");
>>      //$date = date("Y-m-d H:i:s", $date);   
>>      $date = date("Y-m-d H:i:s");    // set date received
>>      list($messageTo,$messageToExt) = split('@',$to);
>>      list($messageFrom,$messageFromExt) = split('@',$from);
>>      
>>      
>>      <SNIP>          
>>                              
>>      
>>      $parts = $mail->fetchParts();
>>      $newImageBaseName = "";
>>      
>>      foreach ( $parts as $part )
>>      {
>>              if ( get_class( $part ) === 'ezcMailText' && $part->subType === 
>>   
>> 'plain' && $bodySet != true )
>>              {
>>                      $bodyFull = trim($part->text);
>>                      $bodySet = true;
>>                      
>>              }
>>              
>>              //////   MANAGE INCOMING IMAGE  //////
>>              if ( get_class( $part ) === 'ezcMailFile' && $imageSet != true) 
>> {
>>                      
>>                      $getImage = getimagesize($part->fileName);
>>                      if (is_array($getImage) && $getImage !== false) {
>>                              $my_image = array_values($getImage);
>>                              list($width, $height, $type, $attr) = $my_image;
>>                              if ($type == 2 && basename($part->fileName) !=  
>> "alltel_logo.jpg") {
>>                                      $my_ext = 
>> strtolower(strrchr(basename($part->fileName),"."));
>>                                      $my_ext = ".jpg"; // quick hack for now
>>                                      if (filesize($part->fileName) < 
>> 4194304) { // only accept  
>> images  < 4MB
>>                                              $imageErr = false;
>>                                              $imageSet = true;
>>                                              break;
>>                                      } else {
>>                                              $imageErr = 1;
>>                                              break;
>>                                      }
>>                              }
>>                      } else {
>>                              $imageErr = 2;
>>                      }
>>              }
>>      }
>>      
>>      $body = reply_splitters($bodyFull);
>>      
>>      if($imageSet) {
>>              $newImageBaseName = $uid . "_" . $mailTimeStamp . $my_ext;
>>              $makeImages = makeThumbnails($part->fileName,$newImageBaseName, 
>>  
>> $width, $height, true);
>>              
>>      }
>>      
>>      <SNIP>  
>>      
>> }
>
> Hi Dave,
>
> I see you are using eZ Components 2007.1.1. There was an issue in  
> the mail parser which was fixed in 2007.2 (http://issues.ez.no/ 
> 12062), and that issue applies to your mail: if there is no space  
> before header values, some parts of the mail are ignored.
>
> Your mail has Content-Location:media1.jpeg (no space after ':'), so  
> that is the problem.
>
> You need to either upgrade to components 2007.2, or modify manually  
> the files:
>
> Mail/src/parser/parts/delivery_status_parser.php, line 77
> Mail/src/parser/interfaces/part_parser.php, line 175
> Mail/src/transports/storage/storage_set.php, line 150
>
> and change the regular expression from "/^([\w-_]*): (.*)/" to "/ 
> ^([\w-_]*):\s?(.*)/". (you might not have '/src' in the paths above  
> depending on your components installation).
>
> Hope this helps.
>
> As a side note, your code contains some hidden errors, which you  
> will see if you write this line in php.ini:
>
> error_reporting = E_ALL | E_STRICT
>
> (for example, $imageSet and $bodySet are not defined). It is  
> considered a good practice to develop with error reporting on.
>
> Cheers,
> Alex.
>
> -- 
> Alexandru Stanoi
> eZ Components System Developer
> eZ Systems | http://ez.no


Alex. Thanks so much. I'm going to upgrade right now. I was meaning  
too do it but haven't gotten to it.
Thanks for the code recommendations. I actually have those lines in my  
code. I pulled a lot of parts out to keep it simple for you. Not to  
say that its not a bit sloppy anyway :). I have a lot to learn about  
better coding. There is no doubt about that.

Thanks again. I'll upgrade and report back if it worked.

Dave
-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components

Reply via email to