...
|
...
|
@@ -22,6 +22,11 @@ class ImapClient { |
|
|
public int $tagNum = 0;
|
|
|
|
|
|
/**
|
|
|
* @var int
|
|
|
*/
|
|
|
public int $timeOut = 3;
|
|
|
|
|
|
/**
|
|
|
* 是否是非阻塞模式
|
|
|
* @var bool
|
|
|
*/
|
...
|
...
|
@@ -33,6 +38,18 @@ class ImapClient { |
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @param int $ttl 秒
|
|
|
* @return $this
|
|
|
* @author:dc
|
|
|
* @time 2025/3/20 10:52
|
|
|
*/
|
|
|
public function setTimeOut(int $ttl)
|
|
|
{
|
|
|
$this->timeOut = $ttl;
|
|
|
return $this;
|
|
|
}
|
|
|
|
|
|
|
|
|
public function open(){
|
|
|
$content = stream_context_create([
|
...
|
...
|
@@ -96,7 +113,7 @@ class ImapClient { |
|
|
|
|
|
$totalBytes = strlen($cmd);
|
|
|
$bytesWritten = 0;
|
|
|
$maxW = 50;
|
|
|
$maxW = $this->timeOut*10;
|
|
|
while ($bytesWritten < $totalBytes) {
|
|
|
$result = fwrite($this->socket, substr($cmd, $bytesWritten));
|
|
|
// 写失败了
|
...
|
...
|
@@ -131,7 +148,7 @@ class ImapClient { |
|
|
* @time 2024/9/13 15:49
|
|
|
*/
|
|
|
protected function readLine(){
|
|
|
$i = 50; // 非阻塞模式下,只等待5秒,没返回数据就返回
|
|
|
$i = $this->timeOut*10; // 非阻塞模式下,只等待5秒,没返回数据就返回
|
|
|
$str = false;
|
|
|
while ($i>0){
|
|
|
$str = fgets($this->socket,2048);
|
...
|
...
|
|