...
|
...
|
@@ -85,6 +85,22 @@ class MailFun { |
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 匹配邮箱
|
|
|
* @param $str
|
|
|
* @return mixed|string
|
|
|
* @author:dc
|
|
|
* @time 2023/11/24 10:04
|
|
|
*/
|
|
|
public static function pregEmail($str){
|
|
|
preg_match('/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/',$str,$email);
|
|
|
if(empty($email[0])){
|
|
|
// 邮箱2
|
|
|
preg_match('/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/',$str,$email);
|
|
|
}
|
|
|
return $email[0]??'';
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 邮件收件人/发件人
|
...
|
...
|
@@ -97,17 +113,18 @@ class MailFun { |
|
|
|
|
|
$strs = explode(',',$str);
|
|
|
foreach ($strs as $k=>$s){
|
|
|
preg_match('/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/',$s,$email);
|
|
|
if(empty($email[0])){
|
|
|
$email = self::pregEmail($s);
|
|
|
|
|
|
if(empty($email)){
|
|
|
$s = [
|
|
|
'email' => '',
|
|
|
'name' => $s
|
|
|
];
|
|
|
}else{
|
|
|
$s = str_replace([$email[0],'"','<','>','>','<'],'',$s);
|
|
|
$s = str_replace([$email,'"','<','>','>','<'],'',$s);
|
|
|
$s = trim($s);
|
|
|
$s = [
|
|
|
'email' => $email[0],
|
|
|
'email' => $email,
|
|
|
'name' => $s
|
|
|
];
|
|
|
}
|
...
|
...
|
|