作者 邓超

调优

... ... @@ -16,4 +16,6 @@ public/storage
cmd/*.log
*.log
.htaccess
404.html
\ No newline at end of file
404.html
shell
public/svg
\ No newline at end of file
... ...
<?php
// 这个是提交脚本
\Co\run(function(){
while (1){
$body = db()->first("select * from `bodies` limit 1 ");
if(!$body || $body['lists_id']>300000000){
echo "执行完成\n";
break;
}
$d = 0;
$len = \Swlib\SaberGM::post('http://172.19.0.5:9527?id='.$body['lists_id'],['body'=>$body['text_html']])->getBody()->getContents();
if(is_numeric($len)&&$len){
$d = db()->delete('bodies',['lists_id'=>$body['lists_id']]);
}
_echo('成功 '.$body['lists_id'].' == '.$d.' == '.$len);
}
});
// 这个是读取备份内容
\Co\run(function(){
$body = \Swlib\SaberGM::get('http://172.19.0.5:9527?id='.$body['lists_id'])->getBody()->getContents();
});
exit();
?>
这里是2个文件哦
------------------------------------------------------------------------------
<?php
/**
* 这个是一个http服务,邮件服务的body内容太大了,把body内容备份到其他服务器,
* 其他服务器放入这个代码 并运行
* 走内网 提交数据
* post 为提交
* get 为获取
*
*/
ini_set("memory_limit", "512M");
// 关闭错误提示 其实这个可有可无 显示了错误也不会输出到前端
//ini_set("display_errors","off");
// 错误级别
error_reporting(E_ALL);
// 时区设置
date_default_timezone_set('Asia/Shanghai');
// 定义 root 目录
define('root_path', __DIR__);
/**
* 服务
* @author:dc
* @time 2025/4/18 15:44
* Class mmd_serv
*/
class mmd_serv
{
/**
* 这个是http服务,对外的
* @var Swoole\Http\Server
*/
private $server;
public function __construct()
{
$this->init_http();
}
/**
* 前端请求处理
* @param \Swoole\Http\Request $request
* @param \Swoole\Http\Response $response
* @author:dc
* @time 2025/4/30 15:42
*/
public function request(\Swoole\Http\Request $request, \Swoole\Http\Response $response)
{
$len = 0;
if($request->server['request_uri']){
}
// print_r($request->get);
$id = intval($request->get['id']??0);
$path = root_path.'/mail/'.($id%10000).'/'.$id.'.log';
$m = strtoupper($request->getMethod());
// get 获取数据
if($m=='GET'){
$len = file_get_contents($path);
}
// 删除数据
elseif($m == 'DELETE'){
$len = unlink($path)?1:0;
}
elseif($m == 'POST'){
$body = $request->post['body']??'';
if($id && $body){
if(!is_dir(dirname($path))){
mkdir(dirname($path),0775,true);
}
$len = file_put_contents($path,$body);
}
}
$response->header("Content-Type", 'text/html; charset=UTF-8');
$response->end($len);
}
/**
* 初始
* @author:dc
* @time 2025/4/30 14:50
*/
private function init_http()
{
// 实例一个服务
$this->server = new Swoole\Http\Server("0.0.0.0", 9527);
// 服务设置
$this->server->set([
// 'open_http2_protocol' => true, // http2协议
// 'log_file' => __DIR__.'/error.log',
// 'log_level' => 0,
'package_max_length' => 20 * 1024 * 1024, // 可以post多大数据
// 'daemonize' => true
]);
// 前端请求时
$this->server->on('request', [$this, 'request']);
}
/**
* 启动http 服务
* @author:dc
* @time 2025/5/10 21:57
*/
public function start()
{
$this->server->start();
}
}
(new mmd_serv())->start();
... ...
... ... @@ -26,7 +26,7 @@ class SyncMail {
public function __construct(int $id, array $data)
{
$this->db = db();
// $this->db = db();
if($data['is_hots']){
return true;
... ... @@ -34,18 +34,15 @@ class SyncMail {
// 是否在指定文件夹内
$f = $this->db->value(folderSql::first($data['folder_id'],'folder'));
if(!$f){
return true;
}
$f = folderAlias($f);
// $f = $this->db->value(folderSql::first($data['folder_id'],'folder'));
// if(!$f){
// return true;
// }
// $f = folderAlias($f);
// 不是预热邮箱
if($f=='收件箱'){
// $this->auto_mail($id,$data);
// if($f=='收件箱'){
// 邮件过滤 这些邮箱都是系统邮箱
// if(!$this->checkEmail($data['from']) && !$this->checkSubject($data['subject'])){
... ... @@ -68,82 +65,7 @@ class SyncMail {
}
}
}
/**
* 自动回复邮箱
* @param $id
* @param $data
* @author:dc
* @time 2024/9/12 15:29
*/
private function auto_mail($id,$data){
$filter = redis()->get('ai_email_filter_lists',[]);
if(!$filter || !is_array($filter)){
$filter = '2 Automatic reply
2 Delivery
2 Automatische Antwort
2 Undeliverable
2 Failure
2 Undelivered
1 noreply
1 postmaster
1 email-notifications
1 mailer-daemon
1 no-reply
2 自动回复
2 Returned mail
2 Autosvar
2 Out Of Office Re
2 Change_of_email_address
2 delivered
2 automatique
2 Reply auto
2 automatic
2 Request received
2 Automatisch
2 Unzustellbar
2 Notification
2 Invitation
2 Automatyczna
2 代开
2 expired';
$filter = explode("\n",$filter);
$filter = array_map(function ($v){
list($t,$str) = [
intval(mb_substr($v,0,1)),
trim(mb_substr($v,1,99)),
];
return [$t,$str];
},$filter);
}
foreach ($filter as $f){
$t = $f[0]??''; // 类型
$str = $f[1]??''; // 值
if(!$str) continue;
$haystack = '';
if($t==2){
$haystack = $data['subject'];
}elseif ($t==1){
$haystack = $data['from'];
}
if(stripos($haystack,$str)!==false){
try {
$this->db->create('lists_auto',['list_id'=>$id],false);
}catch (\Throwable $e){}
break;
}
}
// }
}
... ...
... ... @@ -16,6 +16,7 @@ use Model\bodySql;
use Model\emailSql;
use Model\folderSql;
use Model\listsSql;
use Swlib\SaberGM;
/**
* 同步邮件
... ... @@ -528,12 +529,26 @@ class SyncMail {
}
// 新邮件标记
if($item->getFolderName() == 'INBOX')
if($item->getFolderName() == 'INBOX' && !$data['is_hots']){
redis()->incr('have_new_mail_'.$this->emailId(),120);
// 执行事件
$data['Aicc-Hot-Mail'] = $item->header->get('Aicc-Hot-Mail');
// 通知
if(stripos(trim($data['subject']),'re:')===0){
// 通知黑格 2024-08-22 新上 这个是异步的不会阻塞当前进程
try {
SaberGM::post('https://fob.ai.cc/api/email_new_push',[
'sign' => md5(date('ymd').'fob.ai.cc.email'),
'id' => $id,
'subject' => $data['subject'],
'udate' => $data['udate'],
'from' => $data['from'],
'tos' => array_column($data['to_name'],'email')
]);
}catch (\Throwable $e){
// 就算异常了也不在推送了
}
Event::call('mail_sync_list',$id, $data);
}
}
}
else{
... ...