Beispiel #1
0
 /**
  * Connect the connection, and pass it helo
  *
  * @return Protocol\Smtp
  */
 protected function connect()
 {
     if (!$this->connection instanceof Protocol\Smtp) {
         return $this->lazyLoadConnection();
     }
     $this->connection->connect();
     $this->connection->helo($this->getOptions()->getName());
     return $this->connection;
 }
Beispiel #2
0
 /**
  * @todo Perform xOuath authentication with supplied credentials
  *
  */
 public function auth()
 {
     // Ensure AUTH has not already been initiated.
     // Ensure AUTH has not already been initiated.
     parent::auth();
     $this->_send('AUTH XOAUTH2 ' . $this->_xoauth2_request);
     $this->_expect(235);
     $this->_auth = true;
 }
Beispiel #3
0
 /**
  * Perform PLAIN authentication with supplied credentials
  *
  */
 public function auth()
 {
     // Ensure AUTH has not already been initiated.
     parent::auth();
     $this->_send('AUTH PLAIN');
     $this->_expect(334);
     $this->_send(base64_encode("" . $this->getUsername() . "" . $this->getPassword()));
     $this->_expect(235);
     $this->auth = true;
 }
Beispiel #4
0
 /**
  * Perform LOGIN authentication with supplied credentials
  *
  * @return void
  */
 public function auth()
 {
     // Ensure AUTH has not already been initiated.
     parent::auth();
     $this->_send('AUTH LOGIN');
     $this->_expect(334);
     $this->_send(base64_encode($this->_username));
     $this->_expect(334);
     $this->_send(base64_encode($this->_password));
     $this->_expect(235);
     $this->_auth = true;
 }
Beispiel #5
0
 /**
  * @todo Perform CRAM-MD5 authentication with supplied credentials
  *
  * @return void
  */
 public function auth()
 {
     // Ensure AUTH has not already been initiated.
     parent::auth();
     $this->_send('AUTH CRAM-MD5');
     $challenge = $this->_expect(334);
     $challenge = base64_decode($challenge);
     $digest = $this->_hmacMd5($this->_password, $challenge);
     $this->_send(base64_encode($this->_username . ' ' . $digest));
     $this->_expect(235);
     $this->_auth = true;
 }
Beispiel #6
0
 /**
  * Lazy load the connection, and pass it helo
  * 
  * @return SmtpProtocol
  */
 protected function lazyLoadConnection()
 {
     // Check if authentication is required and determine required class
     $options = $this->getOptions();
     $host = $options->getHost();
     $port = $options->getPort();
     $config = $options->getConnectionConfig();
     $connection = $this->plugin($options->getConnectionClass(), array($host, $port, $config));
     $this->connection = $connection;
     $this->connection->connect();
     $this->connection->helo($options->getName());
     return $this->connection;
 }
Beispiel #7
0
 public function mail($from)
 {
     parent::mail($from);
     $this->mail = $from;
 }
Beispiel #8
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 SmtpProtocol) {
         // Check if authentication is required and determine required class
         $connectionClass = '\\Zend\\Mail\\Protocol\\Smtp';
         if ($this->_auth) {
             $connectionClass .= '\\Auth\\' . ucwords($this->_auth);
         }
         $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->getFrom());
     // Set recipient forward paths
     foreach ($this->_mail->getRecipients() as $recipient) {
         $this->_connection->rcpt($recipient);
     }
     // Issue DATA command to client
     $this->_connection->data($this->header . Mime\Mime::LINEEND . $this->body);
 }