正在显示
7 个修改的文件
包含
52 行增加
和
32 行删除
@@ -529,6 +529,7 @@ class Home extends Base { | @@ -529,6 +529,7 @@ class Home extends Base { | ||
529 | } | 529 | } |
530 | else{ | 530 | else{ |
531 | // 立即发送 | 531 | // 立即发送 |
532 | + $email['hot_email'] = db()->count("select count(*) from `hot_mail` where ".dbWhere(['email'=>$email['email']])); | ||
532 | $result = MailFun::sendEmail($sendData,$email); | 533 | $result = MailFun::sendEmail($sendData,$email); |
533 | if($result[0]){ | 534 | if($result[0]){ |
534 | app()->_json(['messageId' => $result[1]]); | 535 | app()->_json(['messageId' => $result[1]]); |
@@ -281,8 +281,9 @@ class MailFun { | @@ -281,8 +281,9 @@ class MailFun { | ||
281 | return [true,$mail->getLastMessageID()]; | 281 | return [true,$mail->getLastMessageID()]; |
282 | } | 282 | } |
283 | }else{ | 283 | }else{ |
284 | + // ai邮箱才使用代理 | ||
285 | + if(!empty($email['hot_email'])){ | ||
284 | $mail->Port = 9527; | 286 | $mail->Port = 9527; |
285 | - | ||
286 | $mail->send_proxy_host = implode(':',$smtp); | 287 | $mail->send_proxy_host = implode(':',$smtp); |
287 | 288 | ||
288 | foreach (MailProxy::getProxy() as $ip){ | 289 | foreach (MailProxy::getProxy() as $ip){ |
@@ -291,14 +292,13 @@ class MailFun { | @@ -291,14 +292,13 @@ class MailFun { | ||
291 | if($mail->send()){ | 292 | if($mail->send()){ |
292 | return [true,$mail->getLastMessageID()]; | 293 | return [true,$mail->getLastMessageID()]; |
293 | } | 294 | } |
294 | - | ||
295 | } | 295 | } |
296 | 296 | ||
297 | - // 以上全部失败了,再次发送 | 297 | + // 以上全部失败了,再次 本服务器发送 |
298 | $mail->Port = $smtp['port']; | 298 | $mail->Port = $smtp['port']; |
299 | - | ||
300 | - $mail->send_proxy_host = ''; | ||
301 | $mail->Host = $smtp['host']; | 299 | $mail->Host = $smtp['host']; |
300 | + $mail->send_proxy_host = ''; | ||
301 | + } | ||
302 | 302 | ||
303 | // 发送成功直接返回 | 303 | // 发送成功直接返回 |
304 | if($mail->send()){ | 304 | if($mail->send()){ |
@@ -2233,9 +2233,10 @@ class PHPMailer | @@ -2233,9 +2233,10 @@ class PHPMailer | ||
2233 | if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { | 2233 | if ($this->smtp->connect($prefix . $host, $port, $this->Timeout, $options)) { |
2234 | // 是否是代理 如果是代理就需要发送代理认证 | 2234 | // 是否是代理 如果是代理就需要发送代理认证 |
2235 | if($this->send_proxy_host){ | 2235 | if($this->send_proxy_host){ |
2236 | + $this->smtp->proxy_server = true; | ||
2236 | // 代理操作 | 2237 | // 代理操作 |
2237 | $r =rand(1,9999); | 2238 | $r =rand(1,9999); |
2238 | - $this->smtp->client_send('tag1 '.md5('fob.'.$r).' '.$r.' 0 '.$this->send_proxy_host.' 30'); | 2239 | + $this->smtp->client_send('tag1 '.md5('fob.'.$r).' '.$r.' 0 '.$this->send_proxy_host." ".$this->Timeout."\r\n"); |
2239 | $this->edebug($this->smtp->get_lines()); | 2240 | $this->edebug($this->smtp->get_lines()); |
2240 | } | 2241 | } |
2241 | 2242 |
@@ -59,6 +59,12 @@ class SMTP | @@ -59,6 +59,12 @@ class SMTP | ||
59 | const DEFAULT_SECURE_PORT = 465; | 59 | const DEFAULT_SECURE_PORT = 465; |
60 | 60 | ||
61 | /** | 61 | /** |
62 | + * 是否是代理服务器 是代理服务器 就要特殊处理 | ||
63 | + * @var bool | ||
64 | + */ | ||
65 | + public $proxy_server = false; | ||
66 | + | ||
67 | + /** | ||
62 | * The maximum line length allowed by RFC 5321 section 4.5.3.1.6, | 68 | * The maximum line length allowed by RFC 5321 section 4.5.3.1.6, |
63 | * *excluding* a trailing CRLF break. | 69 | * *excluding* a trailing CRLF break. |
64 | * | 70 | * |
@@ -806,6 +812,9 @@ class SMTP | @@ -806,6 +812,9 @@ class SMTP | ||
806 | 812 | ||
807 | foreach ($allDataLines as $allDataLine){ | 813 | foreach ($allDataLines as $allDataLine){ |
808 | $this->client_send($allDataLine, 'DATA'); | 814 | $this->client_send($allDataLine, 'DATA'); |
815 | + if($this->proxy_server){ | ||
816 | + $this->edebug($this->get_lines()); | ||
817 | + } | ||
809 | } | 818 | } |
810 | 819 | ||
811 | //Message data has been sent, complete the command | 820 | //Message data has been sent, complete the command |
@@ -29,10 +29,10 @@ class SmtpClient{ | @@ -29,10 +29,10 @@ class SmtpClient{ | ||
29 | * @author:dc | 29 | * @author:dc |
30 | * @time 2025/3/31 10:27 | 30 | * @time 2025/3/31 10:27 |
31 | */ | 31 | */ |
32 | - public function open(string $out_ip, int $timeout=3){ | 32 | + public function open(string $out_ip, int $timeout=5){ |
33 | $client = new \Swoole\Coroutine\Client(SWOOLE_SOCK_TCP | SWOOLE_SSL); | 33 | $client = new \Swoole\Coroutine\Client(SWOOLE_SOCK_TCP | SWOOLE_SSL); |
34 | $client->set([ | 34 | $client->set([ |
35 | -// 'timeout'=> $timeout, | 35 | + 'timeout'=> $timeout, |
36 | 'ssl_verify_peer' => false,// 关闭证书验证 | 36 | 'ssl_verify_peer' => false,// 关闭证书验证 |
37 | // 'bind_address' => $out_ip, | 37 | // 'bind_address' => $out_ip, |
38 | // 'bind_port' => 36002, | 38 | // 'bind_port' => 36002, |
@@ -44,8 +44,11 @@ class SmtpClient{ | @@ -44,8 +44,11 @@ class SmtpClient{ | ||
44 | throw new Exception($this->host." connection fail. ".$client->errMsg); | 44 | throw new Exception($this->host." connection fail. ".$client->errMsg); |
45 | } | 45 | } |
46 | 46 | ||
47 | + if($client->isConnected()){ | ||
47 | $this->client = $client; | 48 | $this->client = $client; |
48 | - | 49 | + }else{ |
50 | + throw new Exception($this->host." connection fail. "); | ||
51 | + } | ||
49 | } | 52 | } |
50 | 53 | ||
51 | /** | 54 | /** |
@@ -74,16 +77,17 @@ class SmtpClient{ | @@ -74,16 +77,17 @@ class SmtpClient{ | ||
74 | * @author:dc | 77 | * @author:dc |
75 | * @time 2024/9/13 15:49 | 78 | * @time 2024/9/13 15:49 |
76 | */ | 79 | */ |
77 | - public function readLine(){ | 80 | + public function readLine($timeout=5){ |
78 | if($this->is_read === 2){ | 81 | if($this->is_read === 2){ |
79 | - return false; | 82 | + return '220 DATA OK'; |
80 | } | 83 | } |
81 | 84 | ||
82 | if($this->is_read === 1){ | 85 | if($this->is_read === 1){ |
83 | $this->is_read = 2; | 86 | $this->is_read = 2; |
84 | } | 87 | } |
85 | - return $this->client->recv(); | 88 | + $online = $this->client->recv($timeout); |
86 | 89 | ||
90 | + return $online===false ? '500 read time out.' : $online; | ||
87 | } | 91 | } |
88 | 92 | ||
89 | 93 |
@@ -14,10 +14,9 @@ class ProxyService | @@ -14,10 +14,9 @@ class ProxyService | ||
14 | protected static $clients = []; | 14 | protected static $clients = []; |
15 | 15 | ||
16 | 16 | ||
17 | - protected function push(...$params){ | ||
18 | - echo co::getCid()." => "; | ||
19 | - echo implode(' => ',$params); | ||
20 | - return $params; | 17 | + protected function push($msg){ |
18 | + echo 'out '.$msg; | ||
19 | + return $msg; | ||
21 | } | 20 | } |
22 | 21 | ||
23 | /** | 22 | /** |
@@ -35,19 +34,19 @@ class ProxyService | @@ -35,19 +34,19 @@ class ProxyService | ||
35 | 34 | ||
36 | //监听连接进入事件。 | 35 | //监听连接进入事件。 |
37 | $server->on('Connect', function ($server, $fd) { | 36 | $server->on('Connect', function ($server, $fd) { |
38 | - $server->send($fd, "220 proxy client ok\r\n"); | 37 | + $server->send($fd, $this->push("220 proxy client ok\r\n")); |
39 | }); | 38 | }); |
40 | 39 | ||
41 | //监听数据接收事件。 | 40 | //监听数据接收事件。 |
42 | $server->on('Receive', function ($server, $fd, $reactor_id, $data) { | 41 | $server->on('Receive', function ($server, $fd, $reactor_id, $data) { |
43 | -// echo "in ".co::getCid()." ==> ".$data."\n"; | 42 | + echo "in > ".$data; |
44 | // 建立连接 | 43 | // 建立连接 |
45 | if (empty(self::$clients[$fd])) { | 44 | if (empty(self::$clients[$fd])) { |
46 | 45 | ||
47 | try { | 46 | try { |
48 | $auth = new Auth($data); | 47 | $auth = new Auth($data); |
49 | }catch (Throwable $e){ | 48 | }catch (Throwable $e){ |
50 | - $server->send($fd, $e->getMessage()); | 49 | + $server->send($fd, $this->push($e->getMessage())); |
51 | $server->close($fd,true); | 50 | $server->close($fd,true); |
52 | return; | 51 | return; |
53 | } | 52 | } |
@@ -57,23 +56,20 @@ class ProxyService | @@ -57,23 +56,20 @@ class ProxyService | ||
57 | try { | 56 | try { |
58 | self::$clients[$fd]->open($auth->out_ip, $auth->timeOut); | 57 | self::$clients[$fd]->open($auth->out_ip, $auth->timeOut); |
59 | }catch (Throwable $e){ | 58 | }catch (Throwable $e){ |
60 | - $server->send($fd, '500 ' . $e->getMessage()."\r\n"); | 59 | + $server->send($fd,$this->push('500 ' . $e->getMessage()."\r\n")); |
61 | $server->close($fd,true); | 60 | $server->close($fd,true); |
62 | return; | 61 | return; |
63 | } | 62 | } |
64 | 63 | ||
65 | - $line = self::$clients[$fd]->readLine(); | 64 | + $line = self::$clients[$fd]->readLine(1); |
66 | 65 | ||
67 | - if($line) $server->send($fd,$line); | ||
68 | - | ||
69 | - // 发送成功消息 | ||
70 | -// $server->send($fd, "200 OK The proxy server is successfully connected.\r\n"); | 66 | + $server->send($fd,$this->push($line)); |
71 | 67 | ||
72 | } // 正式请求转发 | 68 | } // 正式请求转发 |
73 | else { | 69 | else { |
74 | // 没有连接成功 | 70 | // 没有连接成功 |
75 | if(empty(self::$clients[$fd])){ | 71 | if(empty(self::$clients[$fd])){ |
76 | - $server->send($fd, "500 No proxy server.\r\n"); | 72 | + $server->send($fd, $this->push("500 No proxy server.\r\n")); |
77 | $server->close($fd,true); | 73 | $server->close($fd,true); |
78 | return; | 74 | return; |
79 | } | 75 | } |
@@ -86,12 +82,12 @@ class ProxyService | @@ -86,12 +82,12 @@ class ProxyService | ||
86 | if($num) $line = self::$clients[$fd]->readLine(); | 82 | if($num) $line = self::$clients[$fd]->readLine(); |
87 | 83 | ||
88 | }catch (Throwable $e){ | 84 | }catch (Throwable $e){ |
89 | - echo date('Y-m-d H:i:s').' 协程读取异常 ' .$data." ::".$e->getMessage()."\n"; | 85 | + $line = '500 server error '.$e->getMessage()."\r\n"; |
90 | } | 86 | } |
91 | 87 | ||
92 | // echo 'out '.co::getCid()." => ".$line; | 88 | // echo 'out '.co::getCid()." => ".$line; |
93 | 89 | ||
94 | - if($line!==false) $server->send($fd,$line); | 90 | + if($line!==false) $server->send($fd,$this->push($line)); |
95 | 91 | ||
96 | } | 92 | } |
97 | }); | 93 | }); |
@@ -46,15 +46,24 @@ class MailProxy { | @@ -46,15 +46,24 @@ class MailProxy { | ||
46 | * @var string[] | 46 | * @var string[] |
47 | */ | 47 | */ |
48 | public static $proxyService = [ | 48 | public static $proxyService = [ |
49 | - '43.134.162.250', // 这个是新加坡服务器 代理 | ||
50 | '119.28.113.113', // 这个是新加坡服务器 代理02 | 49 | '119.28.113.113', // 这个是新加坡服务器 代理02 |
51 | - '43.163.110.196', // 这个是新加坡服务器 代理02 | ||
52 | 50 | ||
53 | 51 | ||
54 | 52 | ||
53 | + | ||
54 | + | ||
55 | + '43.134.162.250', // 这个是新加坡服务器 代理 | ||
55 | '43.154.117.107', // 这个是 shopk的那台服务器 | 56 | '43.154.117.107', // 这个是 shopk的那台服务器 |
56 | ]; | 57 | ]; |
57 | 58 | ||
59 | + /** | ||
60 | + * 这些ip 不被分配 这些ip信誉低 | ||
61 | + * @var array | ||
62 | + */ | ||
63 | + public static $noip = [ | ||
64 | + '43.134.162.250', // 这个是新加坡服务器 代理 | ||
65 | + '43.154.117.107', // 这个是 shopk的那台服务器 | ||
66 | + ]; | ||
58 | 67 | ||
59 | /** | 68 | /** |
60 | * 读取代理ip 随机打乱 | 69 | * 读取代理ip 随机打乱 |
@@ -65,7 +74,7 @@ class MailProxy { | @@ -65,7 +74,7 @@ class MailProxy { | ||
65 | public static function getProxy(){ | 74 | public static function getProxy(){ |
66 | $host = self::$proxyService; | 75 | $host = self::$proxyService; |
67 | foreach ($host as $k => $v){ | 76 | foreach ($host as $k => $v){ |
68 | - if($v =='43.154.117.107'){ | 77 | + if(in_array($v,self::$noip)){ |
69 | unset($host[$k]); | 78 | unset($host[$k]); |
70 | } | 79 | } |
71 | } | 80 | } |
@@ -254,7 +263,7 @@ class MailProxy { | @@ -254,7 +263,7 @@ class MailProxy { | ||
254 | $t = date('Y-m-d H:i:s',strtotime("-30 day")); | 263 | $t = date('Y-m-d H:i:s',strtotime("-30 day")); |
255 | foreach ($this::$proxyService as $ip){ | 264 | foreach ($this::$proxyService as $ip){ |
256 | // shopk的不分配 | 265 | // shopk的不分配 |
257 | - if($ip=='43.154.117.107'){ | 266 | + if(in_array($ip,self::$noip)){ |
258 | continue; | 267 | continue; |
259 | } | 268 | } |
260 | $num = db()->count("select count(*) from `mail_proxy` where `status` = 1 and `ip` = '{$ip}'"); | 269 | $num = db()->count("select count(*) from `mail_proxy` where `status` = 1 and `ip` = '{$ip}'"); |
-
请 注册 或 登录 后发表评论