IMP_Compose::addAttachmentFromPart PHP Méthode

addAttachmentFromPart() public méthode

Adds an attachment from Horde_Mime_Part data.
public addAttachmentFromPart ( Horde_Mime_Part $part ) : IMP_Compose_Attachment
$part Horde_Mime_Part The object that contains the attachment data.
Résultat IMP_Compose_Attachment Attachment object.
    public function addAttachmentFromPart($part)
    {
        /* Extract the data from the Horde_Mime_Part. */
        $atc_file = Horde::getTempFile('impatt');
        $stream = $part->getContents(array('stream' => true));
        rewind($stream);
        if (file_put_contents($atc_file, $stream) === false) {
            throw new IMP_Compose_Exception(sprintf(_("Could not attach %s to the message."), $part->getName()));
        }
        return $this->_addAttachment($atc_file, ftell($stream), $part->getName(true), $part->getType());
    }