/** * Add attachments to the message * * @param Postman_Zend_Mail $mail */ private function addAttachmentsToMail(PostmanMessage $message) { $attachments = $message->getAttachments(); if (isset($attachments)) { $this->mandrillMessage['attachments'] = array(); if (!is_array($attachments)) { // WordPress may a single filename or a newline-delimited string list of multiple filenames $attArray = explode(PHP_EOL, $attachments); } else { $attArray = $attachments; } // otherwise WordPress sends an array foreach ($attArray as $file) { if (!empty($file)) { $this->logger->debug("Adding attachment: " . $file); $attachment = array('type' => 'attachment', 'name' => basename($file), 'content' => file_get_contents($file)); array_push($this->mandrillMessage['attachments'], $attachment); } } } }
/** * Add attachments to the message * * @param Postman_Zend_Mail $mail */ private function addAttachmentsToMail(PostmanMessage $message) { $attachments = $message->getAttachments(); if (!is_array($attachments)) { // WordPress may a single filename or a newline-delimited string list of multiple filenames $attArray = explode(PHP_EOL, $attachments); } else { $attArray = $attachments; } // otherwise WordPress sends an array foreach ($attArray as $file) { if (!empty($file)) { $this->logger->debug("Adding attachment: " . $file); $this->email->addAttachment(basename($file)); } } }