22 private $checkingPunycode;
32 return (
new static($address))->validate();
43 if (array_key_exists(
'checkingPunycode', $options))
55 $this->checkingPunycode = (bool)$checkingPunycode;
74 sprintf(
'=?%s?B?%s?=', SITE_CHARSET, base64_encode($this->name)),
80 $address =
"<{$this->email}>";
101 $address = $this->name .
' ';
104 $address .=
"<{$this->email}>";
115 public function set($address)
117 $this->
parse($address);
143 array(
'\\',
'"',
'<',
'>'),
144 array(
'/',
'\'',
'(',
')'),
172 if (!$this->checkMail(
$email))
190 return !empty($this->email);
209 if (preg_match(
'/(.*)<(.+?)>\s*$/is', $address, $matches))
220 private function checkMail(
$email)
222 if (check_email(
$email,
true))
226 if ($this->checkingPunycode)
228 $addressWithPunycodeDomain = $this->convertAddressToPunycode(
$email);
229 if ($addressWithPunycodeDomain)
231 return check_email($addressWithPunycodeDomain,
true);
242 private function convertAddressToPunycode(
$email)
244 if (count(explode(
'@',
$email)) === 2)
246 $domainPart = array_pop(explode(
'@',
$email));
249 $emailAddressName = array_shift(explode(
'@',
$email));
250 $encoder = new \CBXPunycode();
251 if ($encodedDomain = $encoder->encode($domainPart))
253 return $emailAddressName .
'@' . $encodedDomain;
setCheckingPunycode($checkingPunycode)
__construct($address=null, $options=[])