Body.php
959 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Lib\Imap\Request;
use Lib\Imap\Imap;
use Lib\Imap\Parse\Body as ParseBody;
/**
* body邮件内容
* @author:dc
* @time 2024/9/20 14:53
* Class Body
* @package Lib\Imap\Request
*/
class Body extends Request {
/**
* @var Folder
*/
protected Folder $folder;
public function __construct(Imap $imap, Folder $folder)
{
parent::__construct($imap);
$this->folder = $folder;
}
public function exec(): static{return $this;}
/**
* 读取邮件body
* @param int $num
* @param bool $is_uid
* @return ParseBody
* @author:dc
* @time 2024/9/20 15:40
*/
public function get(int $num, bool $is_uid = false):ParseBody {
$this->folder->exec(); // 防止在其他文件夹下面
$this->cmd("%sFETCH %s (RFC822.BODY)", $is_uid ? 'UID ' : '', $num);
return (new ParseBody($this->result ? $this->result[0] : ''));
}
}