Returns the full message text.
public fullMessageText ( array $options = [] ) : mixed | ||
$options | array | Additional options: - stream: (boolean) If true, return a stream for bodytext. DEFAULT: No |
return | mixed | The full message text or a stream resource if 'stream' is true. |
/** */ public function saveMessage() { global $session; $session->close(); $name = ($subject = $this->_contents->getHeader()->getValue('subject')) ? trim(preg_replace('/[^\\pL\\pN-+_. ]/u', '_', $subject), ' _') : 'saved_message'; return array('data' => $this->_contents->fullMessageText(array('stream' => true)), 'name' => $name . '.eml', 'type' => 'message/rfc822'); }
/** */ public function report(IMP_Contents $contents, $action) { global $injector, $registry; $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create(); switch ($this->_format) { case 'redirect': /* Send the message. */ try { $imp_compose->redirectMessage($contents->getIndicesOb()); $imp_compose->sendRedirectMessage($this->_email, false); return true; } catch (IMP_Compose_Exception $e) { $e->log(); } break; case 'digest': default: try { $from_line = $injector->getInstance('IMP_Identity')->getFromLine(); } catch (Horde_Exception $e) { $from_line = null; } /* Build the MIME structure. */ $mime = new Horde_Mime_Part(); $mime->setType('multipart/digest'); $rfc822 = new Horde_Mime_Part(); $rfc822->setType('message/rfc822'); $rfc822->setContents($contents->fullMessageText(array('stream' => true))); $mime->addPart($rfc822); $spam_headers = new Horde_Mime_Headers(); $spam_headers->addMessageIdHeader(); $spam_headers->addHeader('Date', date('r')); $spam_headers->addHeader('To', $this->_email); if (!is_null($from_line)) { $spam_headers->addHeader('From', $from_line); } $spam_headers->addHeader('Subject', sprintf(_("%s report from %s"), $action == IMP_Spam::SPAM ? 'spam' : 'innocent', $registry->getAuth())); /* Send the message. */ try { $recip_list = $imp_compose->recipientList(array('to' => $this->_email)); $imp_compose->sendMessage($recip_list['list'], $spam_headers, $mime, 'UTF-8'); $rfc822->clearContents(); return true; } catch (IMP_Compose_Exception $e) { $e->log(); $rfc822->clearContents(); } break; } return false; }
/** */ public function report(IMP_Contents $contents, $action) { /* Use a pipe to write the message contents. This should be * secure. */ $proc = proc_open($this->_binary, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes); if (!is_resource($proc)) { Horde::log(sprintf('Cannot open spam reporting program: %s', $proc), 'ERR'); return false; } stream_copy_to_stream($contents->fullMessageText(array('stream' => true)), $pipes[0]); fclose($pipes[0]); $stderr = ''; while (!feof($pipes[2])) { $stderr .= fgets($pipes[2]); } fclose($pipes[2]); if (!empty($stderr)) { Horde::log(sprintf('Error reporting spam: %s', $stderr), 'ERR'); } proc_close($proc); return true; }