Beispiel #1
0
 /**
  * 
  * Post-construction tasks to complete object construction.
  * 
  * @return void
  * 
  */
 protected function _postConstruct()
 {
     parent::_postConstruct();
     if ($this->_config['username']) {
         $this->_username = $this->_config['username'];
     }
     if ($this->_config['password']) {
         $this->_password = $this->_config['password'];
     }
 }
Beispiel #2
0
 /**
  * 
  * Sends the Solar_Mail_Message through an SMTP server connection; 
  * lazy-loads the SMTP dependency if needed.
  * 
  * @return bool True on success, false on failure.
  * 
  */
 protected function _send()
 {
     // lazy-load the SMTP dependency if it's not already present
     if (!$this->_smtp) {
         $this->_smtp = Solar::dependency('Solar_Smtp', $this->_config['smtp']);
     }
     // get the headers for the message
     $headers = $this->_mail->fetchHeaders();
     // who are we sending from?
     $from = null;
     foreach ($headers as $header) {
         if ($header[0] == 'Return-Path') {
             $from = trim($header[1], '<>');
             break;
         }
     }
     if (!$from) {
         throw $this->_exception('ERR_NO_RETURN_PATH');
     }
     // who are we sending to?
     $rcpt = $this->_mail->getRcpt();
     // get the content
     $content = $this->_mail->fetchContent();
     // change headers from array to string
     $headers = $this->_headersToString($headers);
     // prepare the message data
     $crlf = $this->_mail->getCrlf();
     $data = $headers . $crlf . $content;
     // make sure we're connected to the server
     if (!$this->_smtp->isConnected()) {
         $this->_smtp->connect();
         $this->_smtp->helo();
     }
     // reset previous connections
     $this->_smtp->rset();
     // tell who this is MAIL FROM
     $this->_smtp->mail($from);
     // tell who this is RCPT TO (each to, cc, and bcc)
     foreach ($rcpt as $addr) {
         $this->_smtp->rcpt($addr);
     }
     // send the message
     $this->_smtp->data($data, $crlf);
     // done!
     return true;
 }