I am having to two image fields. One is thumbnail image which I use in views and another field which holds the images content.

Number of Values for these two fields are as below.

thumbnail_image: 1
content_images: 10

Now when trying post an email with 5 attachments. I am seeing only thumbnail_image is set. Other attachments are processes but not added to field.

I also identified the code thats causing the problem.

function mimerouter_mailhandler($node, $result, $i, $header, $mailbox) {
  
	
  dd('mimerouter_mailhandler');	
  $attachments = mimerouter_get_mailhandler_attachments($node);
  
  if (!empty($attachments)) {
    foreach ($attachments as $attachment) {
    	
      dd('for each attachments as attachment');	
      $field_name = mimerouter_determine_filefield($node, $attachment);
      dd('$field_name '.$field_name);
      if ($field_name != NULL) {
        $items = isset($node->$field_name) ? $node->$field_name : array();
        $field = content_fields($field_name, $node->type);
        dd('content_fields '.$field);
        $account = user_load($node->uid);
        $target_dir = filefield_widget_file_path($field, $account);
        dd('$target_dir '.$target_dir);
        if (!field_file_check_directory($target_dir, FILE_CREATE_DIRECTORY)) {
          watchdog('mimerouter', 'The directory %directory for the file field %field (content type %type) could not be created or is not accessible. A newly emailed file could not be saved in this directory as a consequence, and the attachment was canceled.', array('%directory' => $target_dir, '%field' => $field_name, '%type' => $node->type));
        }