mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-19 21:03:54 -07:00
Extended email validation
* Standard RFC-like email validation. * Will check if there are DNS records that signal that the server accepts emails. This does not entail that the email exists. * Will check for multi-utf-8 chars that can signal an erroneous email name.
This commit is contained in:
parent
10436f55fe
commit
12ee76ff43
2 changed files with 23 additions and 1 deletions
|
@ -384,6 +384,7 @@ $bb_cfg['emailer'] = [
|
|||
],
|
||||
'ssl_type' => '', // SMTP ssl type (ssl or tls)
|
||||
];
|
||||
$bb_cfg['extended_email_validation'] = true; // DNS & RFC checks for entered email addresses
|
||||
|
||||
$bb_cfg['board_email'] = "noreply@$domain_name"; // admin email address
|
||||
$bb_cfg['board_email_form'] = false; // can users send email to each other via board
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
|
||||
namespace TorrentPier\Legacy;
|
||||
|
||||
use Egulias\EmailValidator\EmailValidator;
|
||||
use Egulias\EmailValidator\Validation\DNSCheckValidation;
|
||||
use Egulias\EmailValidator\Validation\MultipleValidationWithAnd;
|
||||
use Egulias\EmailValidator\Validation\RFCValidation;
|
||||
use Egulias\EmailValidator\Validation\SpoofCheckValidation;
|
||||
|
||||
/**
|
||||
* Class Validate
|
||||
* @package TorrentPier\Legacy
|
||||
|
@ -88,7 +94,7 @@ class Validate
|
|||
*/
|
||||
public static function email($email, $check_ban_and_taken = true)
|
||||
{
|
||||
global $lang, $userdata;
|
||||
global $lang, $userdata, $bb_cfg;
|
||||
|
||||
if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
return $lang['EMAIL_INVALID'];
|
||||
|
@ -97,6 +103,21 @@ class Validate
|
|||
return $lang['EMAIL_TOO_LONG'];
|
||||
}
|
||||
|
||||
// Extended email validation
|
||||
if ($bb_cfg['extended_email_validation']) {
|
||||
$validator = new EmailValidator();
|
||||
|
||||
$multipleValidations = new MultipleValidationWithAnd([
|
||||
new RFCValidation(), // Standard RFC-like email validation.
|
||||
new DNSCheckValidation(), // Will check if there are DNS records that signal that the server accepts emails. This does not entail that the email exists.
|
||||
new SpoofCheckValidation() // Will check for multi-utf-8 chars that can signal an erroneous email name.
|
||||
]);
|
||||
|
||||
if (!$validator->isValid($email, $multipleValidations)) {
|
||||
return $lang['EMAIL_INVALID'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_ban_and_taken) {
|
||||
$banned_emails = array();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue