Zend_Mail_Exception example


    public function __construct(array $params)
    {
        if (isset($params['handler'])) {
            if (!$params['handler'] instanceof Zend_Mail_Storage_Abstract) {
                /** * @see Zend_Mail_Exception */
                throw new Zend_Mail_Exception('handler is not a valid mail handler');
            }
            if (!isset($params['id'])) {
                /** * @see Zend_Mail_Exception */
                throw new Zend_Mail_Exception('need a message id with a handler');
            }

            $this->_mail       = $params['handler'];
            $this->_messageNum = $params['id'];
        }
        
        

    public function __construct(array $params)
    {
        if (empty($params['file'])) {
            /** * @see Zend_Mail_Exception */
            throw new Zend_Mail_Exception('no file given in params');
        }

        if (!is_resource($params['file'])) {
            $this->_fh = fopen($params['file'], 'r');
        } else {
            $this->_fh = $params['file'];
        }
        if (!$this->_fh) {
            /** * @see Zend_Mail_Exception */
            

    public function __construct(array $params)
    {
        if (isset($params['file'])) {
            if (!is_resource($params['file'])) {
                $params['raw'] = @file_get_contents($params['file']);
                if ($params['raw'] === false) {
                    /** * @see Zend_Mail_Exception */
                    throw new Zend_Mail_Exception('could not open file');
                }
            } else {
                $params['raw'] = stream_get_contents($params['file']);
            }
        }

        if (!empty($params['flags'])) {
            // set key and value to the same value for easy lookup             $this->_flags = array_merge($this->_flags, array_combine($params['flags'],$params['flags']));
        }

        
public function setType($type)
    {
        $allowed = array(
            Zend_Mime::MULTIPART_ALTERNATIVE,
            Zend_Mime::MULTIPART_MIXED,
            Zend_Mime::MULTIPART_RELATED,
        );
        if (!in_array($type$allowed)) {
            /** * @see Zend_Mail_Exception */
            throw new Zend_Mail_Exception('Invalid content type "' . $type . '"');
        }

        $this->_type = $type;
        return $this;
    }

    /** * Get content type of the message * * @return string */
    
        $sane = true;
        foreach (explode($this->EOL, $this->header) as $line) {
            if (strlen(trim($line)) > 998) {
                $sane = false;
                break;
            }
        }
        if (!$sane) {
            /** * @see Zend_Mail_Transport_Exception */
            throw new Zend_Mail_Exception('At least one mail header line is too long');
        }
    }

    /** * Generate MIME compliant message from the current configuration * * If both a text and HTML body are present, generates a * multipart/alternative Zend_Mime_Part containing the headers and contents * of each. Otherwise, uses whichever of the text or HTML parts present. * * The content part is then prepended to the list of Zend_Mime_Parts for * this message. * * @return void */
Home | Imprint | This part of the site doesn't use cookies.