正在显示
5 个修改的文件
包含
54 行增加
和
27 行删除
@@ -62,7 +62,7 @@ class AutoMail { | @@ -62,7 +62,7 @@ class AutoMail { | ||
62 | $ids[] = $i+$id; | 62 | $ids[] = $i+$id; |
63 | } | 63 | } |
64 | $id = end($ids); | 64 | $id = end($ids); |
65 | - if($id<($maxId-500000)){ | 65 | + if($id<($maxId-100000)){ |
66 | continue; | 66 | continue; |
67 | } | 67 | } |
68 | redis()->rPush('auto_check_ids',implode(',',$ids)); | 68 | redis()->rPush('auto_check_ids',implode(',',$ids)); |
@@ -191,6 +191,7 @@ class SyncMail { | @@ -191,6 +191,7 @@ class SyncMail { | ||
191 | 2 Notification | 191 | 2 Notification |
192 | 2 Invitation | 192 | 2 Invitation |
193 | 2 Automatyczna | 193 | 2 Automatyczna |
194 | +2 代开 | ||
194 | 2 expired'; | 195 | 2 expired'; |
195 | $filter = explode("\n",$filter); | 196 | $filter = explode("\n",$filter); |
196 | 197 |
@@ -36,6 +36,10 @@ class Address { | @@ -36,6 +36,10 @@ class Address { | ||
36 | 36 | ||
37 | /** | 37 | /** |
38 | * 解析地址 | 38 | * 解析地址 |
39 | + * 情况1 "name" <xxx@email.com> | ||
40 | + * 情况2 "name" xxx@email.com | ||
41 | + * 情况3 name xxx@email.com | ||
42 | + * 情况4 xxx@email.com | ||
39 | * @author:dc | 43 | * @author:dc |
40 | * @time 2024/9/11 11:39 | 44 | * @time 2024/9/11 11:39 |
41 | */ | 45 | */ |
@@ -45,7 +49,16 @@ class Address { | @@ -45,7 +49,16 @@ class Address { | ||
45 | 49 | ||
46 | if(!empty($email)){ | 50 | if(!empty($email)){ |
47 | $this->email = $email; | 51 | $this->email = $email; |
48 | - $this->name = trim(str_replace([$email,'"','<','>','>','<'],'',$this->raw)); | 52 | + $this->name = trim($this->raw); |
53 | + $len = strlen($email); | ||
54 | + | ||
55 | + if(substr($this->name,-1)=='>'){ | ||
56 | + $len += 2; | ||
57 | + } | ||
58 | + | ||
59 | + $this->name = substr($this->name,0,-$len); | ||
60 | + $this->name = trim($this->name); | ||
61 | + $this->name = trim($this->name,'"'); | ||
49 | } | 62 | } |
50 | if($this->name){ | 63 | if($this->name){ |
51 | // $this->name = DeCode::decode($this->name); | 64 | // $this->name = DeCode::decode($this->name); |
@@ -64,12 +77,23 @@ class Address { | @@ -64,12 +77,23 @@ class Address { | ||
64 | * @time 2024/9/11 11:43 | 77 | * @time 2024/9/11 11:43 |
65 | */ | 78 | */ |
66 | private function pregEmail(string $str):string { | 79 | private function pregEmail(string $str):string { |
67 | - preg_match('/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/',$str,$email); | ||
68 | - if(empty($email[0])){ | 80 | + preg_match_all('/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/',$str,$email); |
81 | + if(!empty($email[0])){ | ||
82 | + $email = end($email[0]); | ||
83 | + }else{ | ||
84 | + $email = ''; | ||
85 | + } | ||
86 | + if(empty($email)){ | ||
69 | // 邮箱2 | 87 | // 邮箱2 |
70 | - preg_match('/[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/',$str,$email); | 88 | + preg_match_all('/[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/',$str,$email); |
89 | + | ||
90 | + if(!empty($email[0])){ | ||
91 | + $email = end($email[0]); | ||
92 | + }else{ | ||
93 | + $email = ''; | ||
94 | + } | ||
71 | } | 95 | } |
72 | - return str_replace(['<','>'],'',$email[0]??''); | 96 | + return str_replace(['<','>'],'',$email); |
73 | } | 97 | } |
74 | 98 | ||
75 | 99 |
@@ -106,18 +106,19 @@ class Header{ | @@ -106,18 +106,19 @@ class Header{ | ||
106 | 106 | ||
107 | /** | 107 | /** |
108 | * 读取字段 | 108 | * 读取字段 |
109 | - * @param string $name | 109 | + * @param string $name 字段名称 |
110 | + * @param mixed ...$params 额外参数 | ||
110 | * @return mixed | 111 | * @return mixed |
111 | * @author:dc | 112 | * @author:dc |
112 | - * @time 2024/9/11 15:06 | 113 | + * @time 2024/12/11 11:50 |
113 | */ | 114 | */ |
114 | - public function get(string $name):mixed { | 115 | + public function get(string $name,...$params):mixed { |
115 | $name = strtolower($name); | 116 | $name = strtolower($name); |
116 | 117 | ||
117 | $m = 'get'.str_replace(' ','',ucwords(str_replace('-',' ',$name))); | 118 | $m = 'get'.str_replace(' ','',ucwords(str_replace('-',' ',$name))); |
118 | 119 | ||
119 | if(method_exists($this,$m)){ | 120 | if(method_exists($this,$m)){ |
120 | - return $this->{$m}(); | 121 | + return $this->{$m}(...$params); |
121 | } | 122 | } |
122 | 123 | ||
123 | return $this->attributes[$name]??''; | 124 | return $this->attributes[$name]??''; |
@@ -192,15 +193,19 @@ class Header{ | @@ -192,15 +193,19 @@ class Header{ | ||
192 | } | 193 | } |
193 | 194 | ||
194 | 195 | ||
195 | - | ||
196 | /** | 196 | /** |
197 | * 发件人 可能是欺炸 发件人 | 197 | * 发件人 可能是欺炸 发件人 |
198 | - * @return Address | 198 | + * @param bool $isArray 是否返回数组 |
199 | + * @return Address|array | ||
199 | * @author:dc | 200 | * @author:dc |
200 | - * @time 2024/9/11 15:19 | 201 | + * @time 2024/12/11 11:52 |
201 | */ | 202 | */ |
202 | - public function getFrom():Address { | ||
203 | - return Address::make($this->attributes['from']??''); | 203 | + public function getFrom(bool $isArray = false):Address|array { |
204 | + $address = Address::make($this->attributes['from']??''); | ||
205 | + if($isArray){ | ||
206 | + return $address->toArray(); | ||
207 | + } | ||
208 | + return $address; | ||
204 | } | 209 | } |
205 | 210 | ||
206 | /** | 211 | /** |
@@ -274,7 +279,7 @@ class Header{ | @@ -274,7 +279,7 @@ class Header{ | ||
274 | public function toArray():array { | 279 | public function toArray():array { |
275 | $arr = []; | 280 | $arr = []; |
276 | foreach ($this->attributes as $key=>$attr){ | 281 | foreach ($this->attributes as $key=>$attr){ |
277 | - $arr[$key] = $this->get($key); | 282 | + $arr[$key] = $this->get($key,true); |
278 | } | 283 | } |
279 | 284 | ||
280 | return $arr; | 285 | return $arr; |
@@ -300,24 +305,21 @@ class Header{ | @@ -300,24 +305,21 @@ class Header{ | ||
300 | 305 | ||
301 | $str = trim($str); | 306 | $str = trim($str); |
302 | $str = explode("\r\n",$str); | 307 | $str = explode("\r\n",$str); |
303 | - foreach ($str as $k=>$s){ | ||
304 | - $s = trim($s); | ||
305 | - if(preg_match("/^=\?([a-z0-9-.]{3,})\?[bq]\?/i",$s,$code)){ | 308 | + $str = implode('',$str); |
309 | + preg_match_all("/=\?[a-z0-9-.]{3,}\?[bq]\?.*\?=$/Ui",$str,$codes); | ||
310 | + foreach ($codes[0] as $c){ | ||
311 | + if(preg_match("/^=\?([a-z0-9-.]{3,})\?[bq]\?.*\?=$/i",$c,$cc)){ | ||
306 | // 解码 这个函数好像已经转码了, | 312 | // 解码 这个函数好像已经转码了, |
307 | // iso-8859-8-i php 好像没有这个编码 ,阿拉伯 iso-8859-8 | 313 | // iso-8859-8-i php 好像没有这个编码 ,阿拉伯 iso-8859-8 |
308 | // =?iso-8859-8-i?B?4eTu+eog7PTw6en66iDg7CDn4fj6IERjb20gLSD08OnkIO7xIDgyNzUz?= | 314 | // =?iso-8859-8-i?B?4eTu+eog7PTw6en66iDg7CDn4fj6IERjb20gLSD08OnkIO7xIDgyNzUz?= |
309 | - $s = str_replace("=?{$code[1]}?",'=?'.Fun::getEncodingAliases($code[1]).'?',$s); | 315 | + $s = str_replace("=?{$cc[1]}?",'=?'.Fun::getEncodingAliases($cc[1]).'?',$c); |
310 | 316 | ||
311 | $s = mb_decode_mimeheader($s); | 317 | $s = mb_decode_mimeheader($s); |
312 | 318 | ||
313 | - $str[$k] = $s; | ||
314 | - // 转字符编码 | ||
315 | -// return mb_convert_encoding($str,'utf-8',$code[1]); | 319 | + $str = str_replace($c,$s,$str); |
316 | } | 320 | } |
317 | } | 321 | } |
318 | - | ||
319 | - | ||
320 | - return implode(" ",$str); | 322 | + return $str; |
321 | } | 323 | } |
322 | 324 | ||
323 | 325 |
@@ -380,7 +380,7 @@ class SyncMail { | @@ -380,7 +380,7 @@ class SyncMail { | ||
380 | 'cc' => $item->header->getCc(true), | 380 | 'cc' => $item->header->getCc(true), |
381 | 'bcc' => $item->header->getBcc(true), | 381 | 'bcc' => $item->header->getBcc(true), |
382 | 'from' => $item->header->getFrom()->email, | 382 | 'from' => $item->header->getFrom()->email, |
383 | - 'from_name' => $item->header->getFrom()->name, | 383 | + 'from_name' => mb_substr($item->header->getFrom()->name,0,200), |
384 | 'to' => implode(',',array_column($item->header->getTo(true),'email')), | 384 | 'to' => implode(',',array_column($item->header->getTo(true),'email')), |
385 | 'to_name' => $item->header->getTo(true), | 385 | 'to_name' => $item->header->getTo(true), |
386 | // 这个是 邮件的时间 就是header里面带的 一般情况就是发件时间 | 386 | // 这个是 邮件的时间 就是header里面带的 一般情况就是发件时间 |
-
请 注册 或 登录 后发表评论