You are here

public function CheckDnsService::validateEmail in Check DNS 8

Validate email id and its DNS record.

Parameters

string $mail: A mail to check.

Return value

bool TRUE if email is valid and any records are found, FALSE otherwise.

File

src/CheckDnsService.php, line 25

Class

CheckDnsService
Defines the CheckDns service.

Namespace

Drupal\check_dns

Code

public function validateEmail($mail) {

  // Validate e-mail.
  if (filter_var($mail, FILTER_VALIDATE_EMAIL)) {
    $mail = explode('@', $mail);
    return $this
      ->validateHost(end($mail));
  }
  else {
    return FALSE;
  }
}