@@ -91,10 +91,7 @@ protected static function fromBodyStructure($structure)
91
91
protected static function extractPart ($ item )
92
92
{
93
93
global $ countParts ;
94
-
95
- $ countParts ++;
96
- file_put_contents ('p ' .$ countParts .'.json ' , json_encode ($ item , JSON_PRETTY_PRINT ));
97
-
94
+
98
95
$ attribute = null ;
99
96
$ parameters = [];
100
97
@@ -180,11 +177,82 @@ protected static function processSubParts($item, $part)
180
177
}
181
178
182
179
$ part ->parts = [
183
- $ item[ 8 ]
180
+ self :: processSubPartAsMessage ( $ item)
184
181
];
185
182
186
183
return $ part ;
187
184
}
185
+
186
+ protected static function processSubPartAsMessage ($ item )
187
+ {
188
+ $ message = (object ) [
189
+ 'type ' => 1 ,
190
+ 'encoding ' => 0 ,
191
+ 'ifsubtype ' => 1 ,
192
+ 'subtype ' => 'MIXED ' ,
193
+ 'ifdescription ' => 0 ,
194
+ 'ifid ' => 0 ,
195
+ 'ifdisposition ' => 0 ,
196
+ 'ifdparameters ' => 0 ,
197
+ 'ifparameters ' => 1 ,
198
+ 'parameters ' => [
199
+ (object ) [
200
+ 'attribute ' => 'BOUNDARY ' ,
201
+ 'value ' => '=_995890bdbf8bd158f2cbae0e8d966000 '
202
+ ]
203
+ ],
204
+ 'parts ' => [
205
+
206
+ ]
207
+ ];
208
+
209
+ foreach ($ item [8 ] as $ itemPart ) {
210
+ $ part = (object ) [
211
+ 'type ' => 0 ,
212
+ 'encoding ' => 0 ,
213
+ 'ifsubtype ' => 1 ,
214
+ 'subtype ' => 'PLAIN ' ,
215
+ 'ifdescription ' => 0 ,
216
+ 'ifid ' => 0 ,
217
+ 'lines ' => 1 ,
218
+ 'bytes ' => 9 ,
219
+ 'ifdisposition ' => 0 ,
220
+ 'ifdparameters ' => 0 ,
221
+ 'ifparameters ' => 1 ,
222
+ 'parameters ' => []
223
+ ];
224
+
225
+ if (isset ($ itemPart [][0 ])) {
226
+ $ attribute = null ;
227
+ $ dispositionParameters = [];
228
+ $ part ->disposition = $ item [$ dispositionIndex ][0 ];
229
+ if (isset ($ item [$ dispositionIndex ][1 ]) && is_array ($ item [$ dispositionIndex ][1 ])) {
230
+ foreach ($ item [$ dispositionIndex ][1 ] as $ value ) {
231
+ if (empty ($ attribute )) {
232
+ $ attribute = [
233
+ 'attribute ' => $ value ,
234
+ 'value ' => null ,
235
+ ];
236
+ } else {
237
+ $ attribute ['value ' ] = $ value ;
238
+ $ dispositionParameters [] = (object )$ attribute ;
239
+ $ attribute = null ;
240
+ }
241
+ }
242
+ }
243
+ $ part ->dparameters = $ dispositionParameters ;
244
+ $ part ->ifdparameters = 1 ;
245
+ $ part ->ifdisposition = 1 ;
246
+ } else {
247
+ unset($ part ->disposition );
248
+ unset($ part ->dparameters );
249
+ }
250
+
251
+ $ message ->parts [] = $ part ;
252
+ }
253
+
254
+ return $ message ;
255
+ }
188
256
189
257
protected static function extractParameters ($ attributes , $ parameters )
190
258
{
0 commit comments