|
@@ -34,12 +34,24 @@ class Body { |
|
@@ -34,12 +34,24 @@ class Body { |
34
|
|
34
|
|
35
|
|
35
|
|
36
|
/**
|
36
|
/**
|
|
|
37
|
+ * 邮件的header
|
|
|
38
|
+ * @var array
|
|
|
39
|
+ */
|
|
|
40
|
+ private $header = [];
|
|
|
41
|
+
|
|
|
42
|
+
|
|
|
43
|
+ /**
|
37
|
* Body constructor.
|
44
|
* Body constructor.
|
38
|
* @param string $body
|
45
|
* @param string $body
|
39
|
* @param string $fileSavePath
|
46
|
* @param string $fileSavePath
|
40
|
*/
|
47
|
*/
|
41
|
- public function __construct(string $body, string $fileSavePath='/')
|
48
|
+ public function __construct(string $body, string $fileSavePath='/',$header=[])
|
42
|
{
|
49
|
{
|
|
|
50
|
+
|
|
|
51
|
+ if($header){
|
|
|
52
|
+ $this->header = $header;
|
|
|
53
|
+ }
|
|
|
54
|
+
|
43
|
$this->body = $body = trim($body);
|
55
|
$this->body = $body = trim($body);
|
44
|
|
56
|
|
45
|
$this->fileSavePath = $fileSavePath;
|
57
|
$this->fileSavePath = $fileSavePath;
|
|
@@ -89,7 +101,23 @@ class Body { |
|
@@ -89,7 +101,23 @@ class Body { |
89
|
else{
|
101
|
else{
|
90
|
// qq的是base64
|
102
|
// qq的是base64
|
91
|
if(MailFun::isBase64($body)){
|
103
|
if(MailFun::isBase64($body)){
|
|
|
104
|
+
|
|
|
105
|
+ // 可能是图片邮件体,什么都没有
|
|
|
106
|
+ if(!empty($this->header['Content-Type'])){
|
|
|
107
|
+ $ct = explode(";",$this->header['Content-Type']);
|
|
|
108
|
+ // 图片,以后有其他,需要添加
|
|
|
109
|
+ if(in_array($ct[0],['image/png','image/jpg','image/jpeg','image/gif'])){
|
|
|
110
|
+ $isImage = 1;
|
|
|
111
|
+ }
|
|
|
112
|
+ }
|
|
|
113
|
+
|
|
|
114
|
+ if(!empty($isImage)){
|
|
|
115
|
+ $this->setItem(['type'=>'text/plain','body'=>"<img src=\"data:".($ct[0]??'image/png').";base64,".$body."\" />"]);
|
|
|
116
|
+ }else{
|
92
|
$this->setItem(['type'=>'text/plain','body'=>base64_decode($body)]);
|
117
|
$this->setItem(['type'=>'text/plain','body'=>base64_decode($body)]);
|
|
|
118
|
+ }
|
|
|
119
|
+
|
|
|
120
|
+
|
93
|
}else{
|
121
|
}else{
|
94
|
$this->setItem(['type'=>'text/plain','body'=>$body]);
|
122
|
$this->setItem(['type'=>'text/plain','body'=>$body]);
|
95
|
}
|
123
|
}
|