作者 邓超

x

... ... @@ -62,7 +62,7 @@ class AutoMail {
$ids[] = $i+$id;
}
$id = end($ids);
if($id<($maxId-500000)){
if($id<($maxId-100000)){
continue;
}
redis()->rPush('auto_check_ids',implode(',',$ids));
... ...
... ... @@ -191,6 +191,7 @@ class SyncMail {
2 Notification
2 Invitation
2 Automatyczna
2 代开
2 expired';
$filter = explode("\n",$filter);
... ...
... ... @@ -36,6 +36,10 @@ class Address {
/**
* 解析地址
* 情况1 "name" <xxx@email.com>
* 情况2 "name" xxx@email.com
* 情况3 name xxx@email.com
* 情况4 xxx@email.com
* @author:dc
* @time 2024/9/11 11:39
*/
... ... @@ -45,7 +49,16 @@ class Address {
if(!empty($email)){
$this->email = $email;
$this->name = trim(str_replace([$email,'"','<','>','&gt;','&lt;'],'',$this->raw));
$this->name = trim($this->raw);
$len = strlen($email);
if(substr($this->name,-1)=='>'){
$len += 2;
}
$this->name = substr($this->name,0,-$len);
$this->name = trim($this->name);
$this->name = trim($this->name,'"');
}
if($this->name){
// $this->name = DeCode::decode($this->name);
... ... @@ -64,12 +77,23 @@ class Address {
* @time 2024/9/11 11:43
*/
private function pregEmail(string $str):string {
preg_match('/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/',$str,$email);
if(empty($email[0])){
preg_match_all('/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/',$str,$email);
if(!empty($email[0])){
$email = end($email[0]);
}else{
$email = '';
}
if(empty($email)){
// 邮箱2
preg_match('/[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/',$str,$email);
preg_match_all('/[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/',$str,$email);
if(!empty($email[0])){
$email = end($email[0]);
}else{
$email = '';
}
}
return str_replace(['<','>'],'',$email[0]??'');
return str_replace(['<','>'],'',$email);
}
... ...
... ... @@ -106,18 +106,19 @@ class Header{
/**
* 读取字段
* @param string $name
* @param string $name 字段名称
* @param mixed ...$params 额外参数
* @return mixed
* @author:dc
* @time 2024/9/11 15:06
* @time 2024/12/11 11:50
*/
public function get(string $name):mixed {
public function get(string $name,...$params):mixed {
$name = strtolower($name);
$m = 'get'.str_replace(' ','',ucwords(str_replace('-',' ',$name)));
if(method_exists($this,$m)){
return $this->{$m}();
return $this->{$m}(...$params);
}
return $this->attributes[$name]??'';
... ... @@ -192,15 +193,19 @@ class Header{
}
/**
* 发件人 可能是欺炸 发件人
* @return Address
* @param bool $isArray 是否返回数组
* @return Address|array
* @author:dc
* @time 2024/9/11 15:19
* @time 2024/12/11 11:52
*/
public function getFrom():Address {
return Address::make($this->attributes['from']??'');
public function getFrom(bool $isArray = false):Address|array {
$address = Address::make($this->attributes['from']??'');
if($isArray){
return $address->toArray();
}
return $address;
}
/**
... ... @@ -274,7 +279,7 @@ class Header{
public function toArray():array {
$arr = [];
foreach ($this->attributes as $key=>$attr){
$arr[$key] = $this->get($key);
$arr[$key] = $this->get($key,true);
}
return $arr;
... ... @@ -300,24 +305,21 @@ class Header{
$str = trim($str);
$str = explode("\r\n",$str);
foreach ($str as $k=>$s){
$s = trim($s);
if(preg_match("/^=\?([a-z0-9-.]{3,})\?[bq]\?/i",$s,$code)){
$str = implode('',$str);
preg_match_all("/=\?[a-z0-9-.]{3,}\?[bq]\?.*\?=$/Ui",$str,$codes);
foreach ($codes[0] as $c){
if(preg_match("/^=\?([a-z0-9-.]{3,})\?[bq]\?.*\?=$/i",$c,$cc)){
// 解码 这个函数好像已经转码了,
// iso-8859-8-i php 好像没有这个编码 ,阿拉伯 iso-8859-8
// =?iso-8859-8-i?B?4eTu+eog7PTw6en66iDg7CDn4fj6IERjb20gLSD08OnkIO7xIDgyNzUz?=
$s = str_replace("=?{$code[1]}?",'=?'.Fun::getEncodingAliases($code[1]).'?',$s);
$s = str_replace("=?{$cc[1]}?",'=?'.Fun::getEncodingAliases($cc[1]).'?',$c);
$s = mb_decode_mimeheader($s);
$str[$k] = $s;
// 转字符编码
// return mb_convert_encoding($str,'utf-8',$code[1]);
$str = str_replace($c,$s,$str);
}
}
return implode(" ",$str);
return $str;
}
... ...
... ... @@ -380,7 +380,7 @@ class SyncMail {
'cc' => $item->header->getCc(true),
'bcc' => $item->header->getBcc(true),
'from' => $item->header->getFrom()->email,
'from_name' => $item->header->getFrom()->name,
'from_name' => mb_substr($item->header->getFrom()->name,0,200),
'to' => implode(',',array_column($item->header->getTo(true),'email')),
'to_name' => $item->header->getTo(true),
// 这个是 邮件的时间 就是header里面带的 一般情况就是发件时间
... ...