/** * Return all mail headers as an array * * If a boundary is given, a multipart header is generated with a * Content-Type of either multipart/alternative or multipart/mixed depending * on the mail parts present in the {@link $_mail Zend_Mail object} present. * * @param string $boundary * @return array */ protected function _getHeaders($boundary) { if (null !== $boundary) { // Build multipart mail $type = $this->_mail->getType(); if (!$type) { if ($this->_mail->hasAttachments) { $type = Zend_Mime::MULTIPART_MIXED; } elseif ($this->_mail->getBodyText() && $this->_mail->getBodyHtml()) { $type = Zend_Mime::MULTIPART_ALTERNATIVE; } else { $type = Zend_Mime::MULTIPART_MIXED; } } $this->_headers['Content-Type'] = array( $type . '; charset="' . $this->_mail->getCharset() . '";' . $this->EOL . " " . 'boundary="' . $boundary . '"' ); $this->_headers['MIME-Version'] = array('1.0'); $this->boundary = $boundary; } return $this->_headers; }
public function testTypeAccessor() { $mail = new Zend_Mail(); $this->assertNull($mail->getType()); $mail->setType(Zend_Mime::MULTIPART_ALTERNATIVE); $this->assertEquals(Zend_Mime::MULTIPART_ALTERNATIVE, $mail->getType()); $mail->setType(Zend_Mime::MULTIPART_RELATED); $this->assertEquals(Zend_Mime::MULTIPART_RELATED, $mail->getType()); try { $mail->setType('text/plain'); $this->fail('Invalid Zend_Mime type should throw an exception'); } catch (Exception $e) { } }