function SMTP::connected

5.x SMTP.php public SMTP::connected()

Check connection state.

Return value

bool True if connected

File

inc/PHPMailer/src/SMTP.php, line 588

Class

SMTP
PHPMailer RFC821 SMTP email transport class. Implements RFC 821 SMTP commands and provides some utility methods for sending mail to an SMTP server.

Code

public function connected() {
  if (is_resource($this->smtp_conn)) {
    $sock_status = stream_get_meta_data($this->smtp_conn);
    if ($sock_status['eof']) {
      // The socket is valid but we are not connected
      $this->edebug('SMTP NOTICE: EOF caught while checking if connected', self::DEBUG_CLIENT);
      $this->close();

      return false;
    }

    return true; // everything looks good
  }

  return false;
}