...
|
...
|
@@ -21,9 +21,9 @@ class Body { |
|
|
|
|
|
/**
|
|
|
* 消息结构,解析后的邮件体 header
|
|
|
* @var MessageItem
|
|
|
* @var Header
|
|
|
*/
|
|
|
protected MessageItem $msg;
|
|
|
protected Header $header;
|
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -35,22 +35,22 @@ class Body { |
|
|
/**
|
|
|
* Body constructor.
|
|
|
* @param string $result
|
|
|
* @param MessageItem $msg
|
|
|
* @param Header $header
|
|
|
*/
|
|
|
public function __construct(string $result, MessageItem $msg)
|
|
|
public function __construct(string $result, Header $header)
|
|
|
{
|
|
|
$this->raw = $result;
|
|
|
|
|
|
$this->msg = $msg;
|
|
|
$this->header = $header;
|
|
|
|
|
|
|
|
|
// 是否是多段
|
|
|
$boundary = $this->msg->header->getBoundary();
|
|
|
$boundary = $this->header->getBoundary();
|
|
|
if($boundary){
|
|
|
$this->parseBoundaryBody($this->raw,$boundary);
|
|
|
}
|
|
|
// 不是多块级
|
|
|
if(stripos($this->msg->header->get('content-type'),'text/')===0){
|
|
|
if(stripos($this->header->get('content-type'),'text/')===0){
|
|
|
$this->parseRawHtml($this->raw);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -85,11 +85,11 @@ class Body { |
|
|
*/
|
|
|
private function parseRawHtml(string $raw) {
|
|
|
|
|
|
$data = $this->parseMimeHeader('Content-Type: '.$this->msg->header->get('content-type'));
|
|
|
$data = $this->parseMimeHeader('Content-Type: '.$this->header->get('content-type'));
|
|
|
|
|
|
// 设置编码规则
|
|
|
if($this->msg->header->get('Content-Transfer-Encoding')){
|
|
|
$data->set('Content-Transfer-Encoding',$this->msg->header->get('Content-Transfer-Encoding'));
|
|
|
if($this->header->get('Content-Transfer-Encoding')){
|
|
|
$data->set('Content-Transfer-Encoding',$this->header->get('Content-Transfer-Encoding'));
|
|
|
}
|
|
|
|
|
|
// 是否是item fetch
|
...
|
...
|
@@ -163,6 +163,12 @@ class Body { |
|
|
case 'base64':{
|
|
|
$data->body = base64_decode($data->body);break;
|
|
|
}
|
|
|
case 'binary':{
|
|
|
break;
|
|
|
}
|
|
|
case '8bit':{
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return $data;
|
|
|
}
|
...
|
...
|
@@ -284,6 +290,12 @@ class Body { |
|
|
*/
|
|
|
public function getHtmlAndImg():array {
|
|
|
$html = $this->getHtml();
|
|
|
$atta = [];
|
|
|
foreach ($this->items as $item){
|
|
|
if($item->eq('Content-Disposition','inline')){
|
|
|
$atta = $item;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
...
|
...
|
|