mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -07:00
Merge pull request #536 from torrentpier/extended-email-validation
Extended email validation
This commit is contained in:
commit
9419ff6ebf
2 changed files with 23 additions and 1 deletions
|
@ -384,6 +384,7 @@ $bb_cfg['emailer'] = [
|
||||||
],
|
],
|
||||||
'ssl_type' => '', // SMTP ssl type (ssl or tls)
|
'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'] = "noreply@$domain_name"; // admin email address
|
||||||
$bb_cfg['board_email_form'] = false; // can users send email to each other via board
|
$bb_cfg['board_email_form'] = false; // can users send email to each other via board
|
||||||
|
|
|
@ -9,6 +9,12 @@
|
||||||
|
|
||||||
namespace TorrentPier\Legacy;
|
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
|
* Class Validate
|
||||||
* @package TorrentPier\Legacy
|
* @package TorrentPier\Legacy
|
||||||
|
@ -88,7 +94,7 @@ class Validate
|
||||||
*/
|
*/
|
||||||
public static function email($email, $check_ban_and_taken = true)
|
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)) {
|
if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
return $lang['EMAIL_INVALID'];
|
return $lang['EMAIL_INVALID'];
|
||||||
|
@ -97,6 +103,21 @@ class Validate
|
||||||
return $lang['EMAIL_TOO_LONG'];
|
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) {
|
if ($check_ban_and_taken) {
|
||||||
$banned_emails = array();
|
$banned_emails = array();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue