IMP_Compose::attachImapMessage PHP Méthode

attachImapMessage() public méthode

Add mail message(s) from the mail server as a message/rfc822 attachment.
public attachImapMessage ( IMP_Indices $indices ) : string
$indices IMP_Indices An indices object.
Résultat string Subject string.
    public function attachImapMessage($indices)
    {
        if (!count($indices)) {
            return false;
        }
        $attached = 0;
        foreach ($indices as $ob) {
            foreach ($ob->uids as $idx) {
                ++$attached;
                $contents = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($ob->mbox, $idx));
                $headerob = $contents->getHeader();
                $part = new Horde_Mime_Part();
                $part->setCharset('UTF-8');
                $part->setType('message/rfc822');
                $part->setName(_("Forwarded Message"));
                $part->setContents($contents->fullMessageText(array('stream' => true)), array('usestream' => true));
                // Throws IMP_Compose_Exception.
                $this->addAttachmentFromPart($part);
                $part->clearContents();
            }
        }
        if ($attached > 1) {
            return 'Fwd: ' . sprintf(_("%u Forwarded Messages"), $attached);
        }
        if ($name = $headerob['Subject']) {
            $name = Horde_String::truncate($name, 80);
        } else {
            $name = _("[No Subject]");
        }
        return 'Fwd: ' . strval(new Horde_Imap_Client_Data_BaseSubject($name, array('keepblob' => true)));
    }