method getMsg documentation in bbn\Appui\Mailbox

function($msgno, $id, $id_account) { // input $mbox = IMAP stream, $msgno = message id // output all the following: $this->_htmlmsg = ''; $this->_plainmsg = ''; $this->_charset = ''; $this->_attachments = []; // check if "BBN_USER_PATH . 'tmp_mail'" directory exists // HEADER $res = (array)$this->getMsgHeaderinfo($msgno); // add code here to get date, from, to, cc, subject... // BODY STRUCTURE $structure = $this->getMsgStructure($msgno); if (!$structure->parts) { // simple $this->_get_msg_part($msgno, $structure, 0, $id, $id_account); // pass 0 as part-number } else { // multipart: cycle through each part foreach ($structure->parts as $partno0 => $p){ $this->_get_msg_part($msgno, $p, $partno0 + 1, $id, $id_account); // check if the part have fdisposition and if disposition its inline if ($p->parts) { foreach ($p->parts as $partno1 => $p2) { if ($p2->ifdisposition && (strtolower($p2->disposition) === 'inline')) { if ($p2->dparameters) { // search in dparameters when attribute is filename foreach ($p2->dparameters as $dparam) { if (strtolower($dparam->attribute) === 'filename') { $this->_inline_files[] = [ 'name' => $dparam->value, 'id' => substr($p2->id, 1, -1) ]; } } } } } } } } if ($res['html'] = $this->_htmlmsg) { // replace cid links by name $attachments_path = BBN_USER_PATH . 'tmp_mail' . DIRECTORY_SEPARATOR . $id_account . DIRECTORY_SEPARATOR . $id . DIRECTORY_SEPARATOR; $res['html'] = preg_replace_callback( '/src="cid:(.*?)"/', function ($m) use ($msgno, $attachments_path) { $res = $m[0]; $cid = $m[1]; // get the name of the file with the cid in inline array $att = null; foreach ($this->_inline_files as $a) { if ($a['id'] === $cid) { $att = $a['name']; break; } } // encode this file BBN_USER_PATH . 'tmp_mail/' . $att in base64 $file = $attachments_path. $att; // check if the file in an image and get the extension $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); if (in_array($ext, ['jpg', 'jpeg', 'png', 'gif'])) { $type = 'image/' . $ext; if (file_exists($file)) { $base64 = 'src="data:' . $type . ';base64,' . base64_encode(file_get_contents($file)) . '"'; if ($att) { // set src to base64 decode for html $res = $base64; } } } return $res; }, $res['html'] ); $config = HTMLPurifier_HTML5Config::createDefault(); $config->set('URI.AllowedSchemes', ['data' => true]); //\HTMLPurifier_URISchemeRegistry::instance()->register("data", new HTMLPurifier_URIScheme_data()); $purifier = new HTMLPurifier($config); // X::ddump($config, $this->_htmlmsg); $res['html'] = $purifier->purify(quoted_printable_decode($res['html'])); } $res['plain'] = $this->_plainmsg; $res['charset'] = $this->_charset; $res['attachment'] = $this->_attachments; $res['inline'] = $this->_inline_files; return $res; }

BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.