...
|
...
|
@@ -34,12 +34,24 @@ class Body { |
|
|
|
|
|
|
|
|
/**
|
|
|
* 邮件的header
|
|
|
* @var array
|
|
|
*/
|
|
|
private $header = [];
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Body constructor.
|
|
|
* @param string $body
|
|
|
* @param string $fileSavePath
|
|
|
*/
|
|
|
public function __construct(string $body, string $fileSavePath='/')
|
|
|
public function __construct(string $body, string $fileSavePath='/',$header=[])
|
|
|
{
|
|
|
|
|
|
if($header){
|
|
|
$this->header = $header;
|
|
|
}
|
|
|
|
|
|
$this->body = $body = trim($body);
|
|
|
|
|
|
$this->fileSavePath = $fileSavePath;
|
...
|
...
|
@@ -89,7 +101,23 @@ class Body { |
|
|
else{
|
|
|
// qq的是base64
|
|
|
if(MailFun::isBase64($body)){
|
|
|
|
|
|
// 可能是图片邮件体,什么都没有
|
|
|
if(!empty($this->header['Content-Type'])){
|
|
|
$ct = explode(";",$this->header['Content-Type']);
|
|
|
// 图片,以后有其他,需要添加
|
|
|
if(in_array($ct[0],['image/png','image/jpg','image/jpeg','image/gif'])){
|
|
|
$isImage = 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(!empty($isImage)){
|
|
|
$this->setItem(['type'=>'text/plain','body'=>"<img src=\"data:".($ct[0]??'image/png').";base64,".$body."\" />"]);
|
|
|
}else{
|
|
|
$this->setItem(['type'=>'text/plain','body'=>base64_decode($body)]);
|
|
|
}
|
|
|
|
|
|
|
|
|
}else{
|
|
|
$this->setItem(['type'=>'text/plain','body'=>$body]);
|
|
|
}
|
...
|
...
|
|