Esempio n. 1
0
 protected function _addAttachmentBody(array $body)
 {
     foreach ($this->_attachments as $attachment) {
         list($name, $data, $mime) = $attachment;
         $mime = $mime ? $mime : Eden_File::get()->getMimeType($name);
         $data = base64_encode($data);
         $count = ceil(strlen($data) / 998);
         $body[] = '--' . $this->_boundary[1];
         $body[] = 'Content-type: ' . $mime . ';name="' . $name . '"';
         $body[] = 'Content-disposition: attachment;filename="' . $name . '"';
         $body[] = 'Content-transfer-encoding: base64';
         $body[] = NULL;
         for ($i = 0; $i < $count; $i++) {
             $body[] = substr($data, $i * 998, 998);
         }
         $body[] = NULL;
         $body[] = NULL;
     }
     $body[] = '--' . $this->_boundary[1] . '--';
     return $body;
 }