| ... | ... | @@ -39,33 +39,41 @@ class MailProxy { | 
|  |  | 'smtp.gmail.com:465' =>  '10087', | 
|  |  | 'imap.gmail.com:993' =>  '10086', | 
|  |  |  | 
|  |  | 'imap-mail.outlook.com:993' =>  '10088', | 
|  |  | 'smtp-mail.outlook.com:465' =>  '10089', | 
|  |  |  | 
|  |  | 'imap.mail.yahoo.com:993' =>  '10092', | 
|  |  | 'smtp.mail.yahoo.com:465' =>  '10093', | 
|  |  |  | 
|  |  | 'imaphz.qiye.163.com:993' =>  '10080', | 
|  |  | 'smtphz.qiye.163.com:465' =>  '10081', | 
|  |  |  | 
|  |  | 'imap.qiye.aliyun.com:993' =>  '10094', | 
|  |  | 'smtp.qiye.aliyun.com:465' =>  '10095', | 
|  |  |  | 
|  |  | //        'imap.qq.com:993' =>  '10096', | 
|  |  | //        'smtp.qq.com:465' =>  '10097', | 
|  |  |  | 
|  |  | ]; | 
|  |  |  | 
|  |  | /** | 
|  |  | * 代理服务器 地址 | 
|  |  | * @var string[] | 
|  |  | */ | 
|  |  | protected $proxyService = [ | 
|  |  | public static $proxyService = [ | 
|  |  | '43.134.162.250', // 这个是新加坡服务器 代理 | 
|  |  | '119.28.113.113', // 这个是新加坡服务器 代理02 | 
|  |  |  | 
|  |  |  | 
|  |  |  | 
|  |  | '43.154.117.107', // 这个是 shopk的那台服务器 | 
|  |  | ]; | 
|  |  |  | 
|  |  |  | 
|  |  | /** | 
|  |  | * 读取代理ip 随机打乱 | 
|  |  | * @return string[] | 
|  |  | * @author:dc | 
|  |  | * @time 2025/4/15 15:49 | 
|  |  | */ | 
|  |  | public static function getProxy(){ | 
|  |  | $host = self::$proxyService; | 
|  |  | foreach ($host as $k => $v){ | 
|  |  | if($v =='43.154.117.107'){ | 
|  |  | unset($host[$k]); | 
|  |  | } | 
|  |  | } | 
|  |  |  | 
|  |  | shuffle($host); | 
|  |  |  | 
|  |  | return $host; | 
|  |  | } | 
|  |  |  | 
|  |  | /** | 
|  |  | * 分配到的ip服务 | 
|  |  | * @var string | 
| ... | ... | @@ -96,8 +104,13 @@ class MailProxy { | 
|  |  | $this->defaultIp = $default; | 
|  |  | } | 
|  |  |  | 
|  |  | // 先分配 | 
|  |  | $this->assignEmail(); | 
|  |  | // 只分配gmail | 
|  |  | if(stripos($smtp,".gmail.com")){ | 
|  |  | $this->assignEmail(); | 
|  |  | }else{ | 
|  |  | $this->assignIp = false; | 
|  |  | } | 
|  |  |  | 
|  |  |  | 
|  |  | $this->originImapHost = $imap; | 
|  |  |  | 
| ... | ... | @@ -169,7 +182,7 @@ class MailProxy { | 
|  |  | $serve = strtolower(empty($host['host']) ? $host['path'] : $host['host']); | 
|  |  |  | 
|  |  | // 传入的是代理地址 并且是数据库里面已分配的ip | 
|  |  | if(in_array($serve,$this->proxyService)){ | 
|  |  | if(in_array($serve,$this::$proxyService)){ | 
|  |  | // 传入的服务器 和 分配的不一致 更新分配的 | 
|  |  | if($serve != $this->assignIp){ | 
|  |  | $this->assignIp = $serve; | 
| ... | ... | @@ -186,7 +199,7 @@ class MailProxy { | 
|  |  | // 返回不代理 | 
|  |  | $this->assignIp = $serve; | 
|  |  | }else{ | 
|  |  | if(in_array($this->assignIp,$this->proxyService)){ | 
|  |  | if(in_array($this->assignIp,$this::$proxyService)){ | 
|  |  | $port = $this->config[$serve.':'.$port]; // 代理服务器端口 | 
|  |  | } | 
|  |  | } | 
| ... | ... | @@ -208,7 +221,7 @@ class MailProxy { | 
|  |  | private function assignEmail(){ | 
|  |  | $data = db()->throw()->first('select * from mail_proxy where email = "'.$this->email.'"'); | 
|  |  | // 存在记录 并且 还在服务器列表 | 
|  |  | if($data && in_array($data['ip'],$this->proxyService)){ | 
|  |  | if($data && in_array($data['ip'],$this::$proxyService)){ | 
|  |  | $this->assignIp = $data['ip']; | 
|  |  | return ; | 
|  |  | } | 
| ... | ... | @@ -238,12 +251,12 @@ class MailProxy { | 
|  |  |  | 
|  |  | // 一个月活跃用户 | 
|  |  | $t = date('Y-m-d H:i:s',strtotime("-30 day")); | 
|  |  | foreach ($this->proxyService as $ip){ | 
|  |  | foreach ($this::$proxyService as $ip){ | 
|  |  | // shopk的不分配 | 
|  |  | if($ip=='43.154.117.107'){ | 
|  |  | continue; | 
|  |  | } | 
|  |  | $num = db()->count("select count(*) from `mail_proxy` where `status` = 1 and `time` > '{$t}' and `ip` = '{$ip}'"); | 
|  |  | $num = db()->count("select count(*) from `mail_proxy` where `status` = 1 and `ip` = '{$ip}'"); | 
|  |  | // 每个ip分配1000个 | 
|  |  | if($num<1000){ | 
|  |  | $this->assignIp = $ip; | 
| ... | ... | @@ -301,6 +314,14 @@ class MailProxy { | 
|  |  | } | 
|  |  |  | 
|  |  |  | 
|  |  | public function toArray(){ | 
|  |  | return [ | 
|  |  | 'smtp'  =>  $this->getOriginSmtpHost(), | 
|  |  | 'imap'  =>  $this->getOriginImapHost(), | 
|  |  | 'proxy_smtp'  =>  $this->getSmtpProxy(), | 
|  |  | 'proxy_imap'  =>  $this->getImapProxy(), | 
|  |  | ]; | 
|  |  | } | 
|  |  |  | 
|  |  | } | 
|  |  |  | 
... | ... |  |