You are here

function _email_verify_read_line in Email Verify 7.2

SMTP Single line read.

Reads a single response line from SMTP server and identifies response CODE and Following Character (" " or "-")

Parameters

string $connect: A single line from the connection response string from the server.

bool $debugging_mode: Whether to collect debugging information or not.

array $debugging_text: An array of strings, each of which are a line of debugging information.

string $date_time_format: The data and time format to use for the debugging information.

Return value

array A sinlge line of the response from the server, formatted for use by this module. THe array consists of three elements:

  • code: The numeric response code from the server.
  • next_char: A character indicating if there are more lines to follow, or if this is the last line. A "-" indicates that more text is following, and a " " (space) indicates that there is no more text.
  • line: The string of text for this line from the server's response.
1 call to _email_verify_read_line()
_email_verify_read_all_lines in ./email_verify.inc
Read response from SMTP server, multiline compatible.

File

./email_verify.inc, line 867
Checks the email address for validity.

Code

function _email_verify_read_line($connect, $debugging_mode, array &$debugging_text, $date_time_format) {
  if ($debugging_mode) {
    $debugging_text[] = t('Reading a single line of the connection response (!date_time).', array(
      '!date_time' => format_date(time(), $date_time_format),
    ));
  }
  $response = fgets($connect, 1024);
  $strlen = strlen($response);
  $code = '';

  // Try to get response code: all numeric characters at the begginging of the
  // response string.
  $i = 0;
  for ($i = 0; $i <= $strlen; $i++) {
    $char = substr($response, $i, 1);
    if (!is_numeric($char)) {
      break;
    }
    $code .= $char;
  }

  // If there is a slash character after the response code then more lines are
  // to be expected.
  // @see https://bugs.php.net/bug.php?id=6537
  // (That bug was fixed in PHP between 2001-01-10 and 2002-06-02. The reference
  // is included here for background information.)
  $next_char = substr($response, $i, 1);
  if ($debugging_mode) {
    $debugging_text[] = t('Done reading a single line of the connection response. The results were: Code: "%code", More lines: "@next_char" (!more_lines), Response: "%response" (!date_time).', array(
      '%code' => $code,
      '@next_char' => $next_char,
      '%response' => $response,
      '!more_lines' => $next_char == " " ? 'no' : 'yes',
      '!date_time' => format_date(time(), $date_time_format),
    ));
  }
  return array(
    'code' => $code,
    'next_char' => $next_char,
    'line' => $response,
  );
}