summaryrefslogtreecommitdiff
path: root/it_mail.class
diff options
context:
space:
mode:
Diffstat (limited to 'it_mail.class')
-rw-r--r--it_mail.class22
1 files changed, 11 insertions, 11 deletions
diff --git a/it_mail.class b/it_mail.class
index 0705c15..eb2cbb9 100644
--- a/it_mail.class
+++ b/it_mail.class
@@ -56,8 +56,6 @@ class it_mail
var $flags = "";
var $charset;
- static $addr_regex = "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])";
-
/**
* Construct a new email message. Headers and body can be added later.
* Note: Headers To, Cc, Bcc can be arrays
@@ -408,20 +406,22 @@ static function send_smtp_cmd($fp, $cmd, &$answer, $timeoutok = false, $failcode
/* Return errors found with email address, null otherwise
*/
-static function address_error($addresses)
+static function address_error($addresslist)
{
- foreach (str_split($addresses) as $char)
+ foreach (str_split($addresslist) as $char)
{
- $quoted = $char == '"' ? !$quoted : $quoted;
- if ($char == ',' && !$quoted)
+ if ($char == '"')
+ $quoted = !$quoted;
+ else if ($char == ',' && !$quoted)
$n++;
- else
- $emails[$n] .= $char;
+ else if (!$quoted)
+ $addresses[$n] .= $char;
}
- foreach ($emails as $email)
- if (!it::match(self::$addr_regex, $email) && !it::match('^\s*[a-z][-a-z0-9]*\s*$', $email))
- return "invalid format on $email";
+ foreach ($addresses as $address)
+ if (($email = it::match('<([^>]*)', $address) ?? $address))
+ if (filter_var($email, FILTER_VALIDATE_EMAIL) === false && !it::match('^\s*[a-z][-a-z0-9]*\s*$', $email))
+ return "invalid format on $email";
}