Add direct validation function for noda mail checker
This commit is contained in:
parent
f18e4c3edc
commit
cc0997f412
@ -107,4 +107,26 @@ final class NodaMailChecker {
|
||||
return self::validateMailDomainAccessibilityCached($mysqli, $domain);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates mail address, throwing an exception if the mail address is not valid.
|
||||
*
|
||||
* @param MDMysqli $mysqli DB connection.
|
||||
* @param string $mail_address Address.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function validateMail(MDMysqli $mysqli, string $mail_address):string {
|
||||
|
||||
if (empty($mail_address)) return $mail_address;
|
||||
|
||||
$mail_address = MD_STD_IN::sanitize_email($mail_address);
|
||||
|
||||
if (self::validateMailByDomainAccessibilityCached($mysqli, $mail_address) === false) {
|
||||
throw new MDInvalidEmail("The host name of the entered mail address is invalid");
|
||||
}
|
||||
|
||||
return $mail_address;
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user