示例#1
0
 /**
  * Send an email via the SMTP connection protocol
  *
  * The connection via the protocol adapter is made just-in-time to allow a
  * developer to add a custom adapter if required before mail is sent.
  *
  * @return void
  * @todo Rename this to sendMail, it's a public method...
  */
 public function _sendMail()
 {
     // If sending multiple messages per session use existing adapter
     if (!$this->_connection instanceof Zend_Mail_Protocol_Smtp) {
         // Check if authentication is required and determine required class
         $connectionClass = 'Zend_Mail_Protocol_Smtp';
         if ($this->_auth) {
             $connectionClass .= '_Auth_' . ucwords($this->_auth);
         }
         if (!class_exists($connectionClass)) {
             Zend_Loader::loadClass($connectionClass);
         }
         $this->setConnection(new $connectionClass($this->_host, $this->_port, $this->_config));
         $this->_connection->connect();
         $this->_connection->helo($this->_name);
     } else {
         // Reset connection to ensure reliable transaction
         $this->_connection->rset();
     }
     // Set sender email address
     $this->_connection->mail($this->_mail->getReturnPath());
     // Set recipient forward paths
     foreach ($this->_mail->getRecipients() as $recipient) {
         $this->_connection->rcpt($recipient);
     }
     // Issue DATA command to client
     $this->_connection->data($this->header . Zend_Mime::LINEEND . $this->body);
 }
示例#2
0
 /**
  * @depends testEhlo
  * @group ZF-1377
  */
 public function testRsetExpects220()
 {
     $expectedDialog = $this->_connectAndEhlo();
     // Microsoft ESMTP server responds to RSET with 220 rather than 250
     $this->_protocol->responseBuffer = array('220 OK');
     $expectedDialog[] = 'RSET';
     $expectedDialog[] = '220 OK';
     $this->_protocol->rset();
     $this->assertEquals($expectedDialog, $this->_protocol->dialog);
 }