public function MailhandlerCommandsFiles::process in Mailhandler 7.2
Same name and namespace in other branches
- 6.2 plugins/mailhandler/commands/MailhandlerCommandsFiles.class.php \MailhandlerCommandsFiles::process()
Parse attachments from message mimeparts.
Overrides MailhandlerCommands::process
File
- plugins/
mailhandler/ commands/ MailhandlerCommandsFiles.class.php, line 15 - MailhandlerCommandsFiles class.
Class
- MailhandlerCommandsFiles
- Provides file attachments.
Code
public function process(&$message, $source) {
$message['attachments'] = array();
foreach ($message['mimeparts'] as $attachment) {
// 'unnamed_attachment' files are not really attachments, but mimeparts like HTML or Plain Text.
// We only want to save real attachments, like images and files.
if ($attachment->filename !== 'unnamed_attachment') {
$filename = mb_decode_mimeheader($attachment->filename);
$cid = NULL;
if (!empty($attachment->id)) {
$cid = trim($attachment->id, '<>');
}
$message['attachments'][] = new MailhandlerAttachmentEnclosure($filename, $attachment->filemime, $attachment->data, $cid);
}
}
unset($message['mimeparts']);
}