Exemple #1
0
 /**
  * Send new message.
  *
  * @access   pubic
  * @param    Mail $oMessage
  * @return   bool
  * @throws   Exception
  * @throws   Exception\Fatal
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function send(Mail $oMessage)
 {
     if (!$this->isConnected) {
         $this->connect();
         $this->authenticate();
     }
     foreach ($oMessage->getFrom() as $sVal) {
         $this->sendCommand('from', $sVal);
     }
     foreach ($oMessage->getTo() as $sVal) {
         $this->sendCommand('to', $sVal);
     }
     if (count($oMessage->getCC()) > 0) {
         foreach ($oMessage->getCC() as $sVal) {
             $this->sendCommand('to', $sVal);
         }
     }
     if (count($oMessage->getBcc()) > 0) {
         foreach ($oMessage->getBcc() as $sVal) {
             $this->sendCommand('to', $sVal);
         }
     }
     $this->sendCommand('data');
     $this->sendData($oMessage->getMessageHeaders() . preg_replace('/^\\./m', '..$1', $oMessage->getMessageBody()));
     $this->sendData('.');
     $sReply = $this->getData();
     if (strncmp($sReply, '250', 3) !== 0) {
         throw new Exception('Error with sending body');
     }
     return TRUE;
 }