public function testBoundary() { // check boundary for uniqueness $m1 = new Mime\Mime(); $m2 = new Mime\Mime(); $this->assertNotEquals($m1->boundary(), $m2->boundary()); // check instantiating with arbitrary boundary string $myBoundary = 'mySpecificBoundary'; $m3 = new Mime\Mime($myBoundary); $this->assertEquals($m3->boundary(), $myBoundary); }
/** * Send a mail using this transport * * @param \Zend\Mail\Mail $mail * @access public * @return void * @throws \Zend\Mail\Transport\Exception if mail is empty */ public function send(\Zend\Mail\Mail $mail) { $this->_isMultipart = false; $this->_mail = $mail; $this->_parts = $mail->getParts(); $mime = $mail->getMime(); // Build body content $this->_buildBody(); // Determine number of parts and boundary $count = count($this->_parts); $boundary = null; if ($count < 1) { throw new Exception('Empty mail cannot be sent'); } if ($count > 1) { // Multipart message; create new MIME object and boundary $mime = new Mime\Mime($this->_mail->getMimeBoundary()); $boundary = $mime->boundary(); } elseif ($this->_isMultipart) { // multipart/alternative -- grab boundary $boundary = $this->_parts[0]->boundary; } // Determine recipients, and prepare headers $this->recipients = implode(',', $mail->getRecipients()); $this->_prepareHeaders($this->_getHeaders($boundary)); // Create message body // This is done so that the same \Zend\Mail\Mail object can be used in // multiple transports $message = new Mime\Message(); $message->setParts($this->_parts); $message->setMime($mime); $this->body = $message->generateMessage($this->EOL); // Send to transport! $this->_sendMail(); }