作者 邓超

优化

... ... @@ -290,7 +290,7 @@ function sync($email_id,$worker_id){
$mailServer = new Lib\Mail\Mail($email['email'],base64_decode($email['password']),$email['imap']);
// 登录服务器
if(!$mailServer->login()){
if($mailServer->login()!==1){
return 2;
}
... ...
... ... @@ -145,13 +145,13 @@ class Imap {
* 调试模式
* @var bool
*/
private $debug = false;
static bool $debug = false;
/**
* 调试,记录日志的目录
* @var string
*/
private $debugWritePath = '';
static string $debugWritePath = '';
/**
* 登录imap服务器
... ... @@ -1052,8 +1052,8 @@ class Imap {
* @time 2022/12/6 11:10
*/
public function debug($debug=true,$logPath=''){
$this->debug = $debug;
$this->debugWritePath = $logPath ? $logPath : LOG_PATH;
$this::$debug = $debug;
$this::$debugWritePath = $logPath ? $logPath : LOG_PATH;
}
/**
... ... @@ -1063,11 +1063,16 @@ class Imap {
* @time 2022/12/6 11:13
*/
private function log(string $message){
if($this->debug){
if(!is_dir($this->debugWritePath)){
@mkdir($this->debugWritePath,0775,true);
if($this::$debug){
if($this::$debugWritePath == 'echo'){
echo $message."\n";
}else{
if(!is_dir($this::$debugWritePath)){
@mkdir($this::$debugWritePath,0775,true);
}
@file_put_contents($this::$debugWritePath.'/imap.log',date('Y-m-d H:i:s ').$message.PHP_EOL,FILE_APPEND);
}
@file_put_contents($this->debugWritePath.'/imap.log',date('Y-m-d H:i:s ').$message.PHP_EOL,FILE_APPEND);
}
}
... ... @@ -1131,6 +1136,9 @@ class Imap {
if($status == 'bad'){
logs($cmd);
throw new \Exception('request bad:'.$line);
}elseif($status == 'no'){
logs($cmd);
throw new \Exception('命令失败 NO:'.$line);
}
}else{
if(!preg_match("/^\*\s\w/",$line)){
... ...