Advertisement
kangjaz

new_email

Mar 20th, 2018
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. protected function _smtp_connect()
  2.     {
  3.         if (is_resource($this->_smtp_connect))
  4.         {
  5.             return TRUE;
  6.         }
  7.  
  8.         $ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : '';
  9.  
  10.         /* $this->_smtp_connect = fsockopen($ssl.$this->smtp_host,
  11.                             $this->smtp_port,
  12.                             $errno,
  13.                             $errstr,
  14.                             $this->smtp_timeout); */
  15.  
  16.         $context = stream_context_create(['ssl' => [
  17.             //'ciphers' => 'RC4-MD5',
  18.             'verify_host' => FALSE,
  19.             'verify_peer_name' => FALSE,
  20.             'verify_peer' => FALSE
  21.         ]]);
  22.  
  23.         $this->_smtp_connect = stream_socket_client($ssl.$this->smtp_host.':'.$this->smtp_port, $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
  24.        
  25.         if ( ! is_resource($this->_smtp_connect))
  26.         {
  27.             $this->_set_error_message('lang:email_smtp_error', $errno.' '.$errstr);
  28.             return FALSE;
  29.         }
  30.  
  31.         stream_set_timeout($this->_smtp_connect, $this->smtp_timeout);
  32.         $this->_set_error_message($this->_get_smtp_data());
  33.  
  34.         if ($this->smtp_crypto === 'tls')
  35.         {
  36.             $this->_send_command('hello');
  37.             $this->_send_command('starttls');
  38.  
  39.             $crypto = stream_socket_enable_crypto($this->_smtp_connect, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT);
  40.  
  41.             if ($crypto !== TRUE)
  42.             {
  43.                 $this->_set_error_message('lang:email_smtp_error', $this->_get_smtp_data());
  44.                 return FALSE;
  45.             }
  46.         }
  47.  
  48.         return $this->_send_command('hello');
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement