Example #1
0
 /**
  * Does the actual work of sending the message.
  *
  * @codeCoverageIgnore
  *
  * @param \BLW\Type\MIME\IMessage $Message
  *            Message to send.
  * @return integer ITransport::RESULT_FLAGS
  */
 public function doSend(IMessage $Message)
 {
     // Convert Message to MIME format
     if (is_callable(array($Message, 'createMimeMessage'))) {
         $MimeMessage = $Message->createMimeMessage();
         $this->_Recipients = $this->parseRecipients($Message);
         $this->_Header = $MimeMessage->getHeader();
         $this->_Body = $MimeMessage->getBody();
         return ITransport::SUCCESS;
     }
     // Invalid $VARIABLE
     return ITransport::ERROR;
 }
Example #2
0
 /**
  * @depends test_createMimeMessage
  * @covers ::sendWith()
  */
 public function test_sendWith()
 {
     $Transport = new Transport($this->getMockForAbstractClass('\\BLW\\Type\\IMediator'));
     $this->generateMessage();
     $this->assertEquals(ITransport::SUCCESS, $this->Message->sendWith($Transport, -1), 'IMessage::sendWidth() should return ITransport::SUCCESS');
     $this->assertInstanceof('\\BLW\\Type\\MIME\\IHead', $Transport->getMimeHead(), 'IMessage::sendWidth() produced an invalid MIME head');
     $this->assertInstanceof('\\BLW\\Type\\MIME\\IBody', $Transport->getMimeBody(), 'IMessage::sendWidth() produced an invalid MIME body');
     $this->assertCount(3, $Transport->getReceipients(), 'IMessage::sendWidth should send to 3 recipients');
 }
Example #3
0
 /**
  * Does the actual work of sending the message.
  *
  * @codeCoverageIgnore
  *
  * @link http://www.php.net/manual/en/function.mail.php mail()
  *
  * @throws \BLW\Model\ErrorException If there is an error sending the mail.
  *
  * @param \BLW\Type\Mail\IMessage $Message
  *            Message to send.
  * @return integer ITransport::RESULT_FLAGS
  */
 public function doSend(IMessage $Message)
 {
     $MimeMessage = $Message->createMimeMessage();
     $To = array();
     // Gather recipients
     foreach ($this->parseRecipients($Message) as $Recipient) {
         // Is current entry an email address?
         if ($Recipient instanceof IEmailAddress) {
             // Add it to recipients
             $To[] = strval($Address);
         }
     }
     $To = implode(', ', $To);
     // Try to send message
     if (!@mail($To, $Message->getSubject(), strval($MimeMessage->getBody()), strval($MimeMessage->getHeader()))) {
         throw new ErrorException(error_get_last());
     }
     // Success
     return ITransport::SUCCESS;
 }