IMAP bijlage downloaden
Momenteel ben ik bezig met een IMAP functie, ik kan me mail al binnen halen. Echter zit ik nu met een probleem, hoe download ik de bijlages van de betreffende e-mail?
Dit heb ik al om te kijken of er een bijlage aan de mail is gekoppeld en of deze toegelaten mag worden.
Code (php)
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
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
<?php
//We gaan nu kijken of er een bijlage aan de mail is gekoppeld
$info = imap_fetchstructure($mbox, $I);
//Tellen hoeveel parts hij heeft
$numparts = count($info->parts);
// Als er meerdere parts zijn dan zit er bijlage bij
if ($numparts > 1)
{
foreach ($info->parts as $part)
{
// Controleren of het een bijlage is
if ($part->disposition == "ATTACHMENT")
{
// print out the file name
if(substr($part->dparameters[0]->value, -3) != 'exe' && substr($part->dparameters[0]->value, -3) != 'pif' && substr($part->dparameters[0]->value, -3) != 'vbs')
{
//Hier moet dus komen hoe ik hem moet downloaden...
echo 'Filename: ', $part->dparameters[0]->value . '<br />';
}
else
{
echo 'Het bestand ' . $part->dparameters[0]->value . ' is geblokkeerd<br />';
}
}
}
}
else
{
echo 'Geen bijlages gevonden<br /><br />';
}
?>
//We gaan nu kijken of er een bijlage aan de mail is gekoppeld
$info = imap_fetchstructure($mbox, $I);
//Tellen hoeveel parts hij heeft
$numparts = count($info->parts);
// Als er meerdere parts zijn dan zit er bijlage bij
if ($numparts > 1)
{
foreach ($info->parts as $part)
{
// Controleren of het een bijlage is
if ($part->disposition == "ATTACHMENT")
{
// print out the file name
if(substr($part->dparameters[0]->value, -3) != 'exe' && substr($part->dparameters[0]->value, -3) != 'pif' && substr($part->dparameters[0]->value, -3) != 'vbs')
{
//Hier moet dus komen hoe ik hem moet downloaden...
echo 'Filename: ', $part->dparameters[0]->value . '<br />';
}
else
{
echo 'Het bestand ' . $part->dparameters[0]->value . ' is geblokkeerd<br />';
}
}
}
}
else
{
echo 'Geen bijlages gevonden<br /><br />';
}
?>
Gewijzigd op 01/01/1970 01:00:00 door Kitty N
http://www.phphulp.nl/php/scripts/4/1356/
Heb ik al meerdere malen met succes gebruikt (ook bijlages)
Via die $info krijg ik de volgende gegevens terug:
Code (php)
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
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
[1] => stdClass Object
(
[type] => 3
[encoding] => 3
[ifsubtype] => 1
[subtype] => MSWORD
[ifdescription] => 1
[description] => Intranet-standaard.doc
[ifid] => 0
[bytes] => 158346
[ifdisposition] => 1
[disposition] => ATTACHMENT
[ifdparameters] => 1
[dparameters] => Array
(
[0] => stdClass Object
(
[attribute] => FILENAME
[value] => Intranet-standaard.doc
)
)
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => NAME
[value] => Intranet-standaard.doc
)
)
)
(
[type] => 3
[encoding] => 3
[ifsubtype] => 1
[subtype] => MSWORD
[ifdescription] => 1
[description] => Intranet-standaard.doc
[ifid] => 0
[bytes] => 158346
[ifdisposition] => 1
[disposition] => ATTACHMENT
[ifdparameters] => 1
[dparameters] => Array
(
[0] => stdClass Object
(
[attribute] => FILENAME
[value] => Intranet-standaard.doc
)
)
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => NAME
[value] => Intranet-standaard.doc
)
)
)
Zou ik via fopen, fwrite en fread het bestand kunnen opslaan op de server?
Gewijzigd op 01/01/1970 01:00:00 door kitty N
Code (php)
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
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
<?php
$structure = imap_fetchstructure($mbox, $I , FT_UID);
$parts = $structure->parts;
$fpos=2;
for($i = 1; $i < count($parts); $i++)
{
$message["pid"][$i] = ($i);
$part = $parts[$i];
if($part->disposition == "ATTACHMENT")
{
if(substr($parts[$i]->dparameters[0]->value, -3) != 'exe' && substr($parts[$i]->dparameters[0]->value, -3) != 'pif' && substr($parts[$i]->dparameters[0]->value, -3) != 'vbs')
{
$message["type"][$i] = $message["attachment"]["type"][$part->type] . "/" . strtolower($part->subtype);
$message["subtype"][$i] = strtolower($part->subtype);
$ext=$part->subtype;
$params = $part->dparameters;
$filename=$part->dparameters[0]->value;
// De orginele naam van de bijlage behouden
$orgbijlages .= $parts[$i]->dparameters[0]->value . ' , ';
// Een unieke naam maken voor de bijlage, zodat deze niet overschreden kan worden.
$Tijdelijkebijlage = date('Ymd') . '-' . uniqid() . '.' . substr($parts[$i]->dparameters[0]->value, -3);
$mege="";
$data="";
$mege = imap_fetchbody($mbox,$I,$fpos);
$filename="./bijlages/" . $Tijdelijkebijlage;
$fp=fopen($filename,w);
$data=getdecodevalue($mege,$part->type);
fputs($fp,$data);
fclose($fp);
$fpos+=1;
$tmpbijlages .= $Tijdelijkebijlage . ' , ';
}
}
}
?>
$structure = imap_fetchstructure($mbox, $I , FT_UID);
$parts = $structure->parts;
$fpos=2;
for($i = 1; $i < count($parts); $i++)
{
$message["pid"][$i] = ($i);
$part = $parts[$i];
if($part->disposition == "ATTACHMENT")
{
if(substr($parts[$i]->dparameters[0]->value, -3) != 'exe' && substr($parts[$i]->dparameters[0]->value, -3) != 'pif' && substr($parts[$i]->dparameters[0]->value, -3) != 'vbs')
{
$message["type"][$i] = $message["attachment"]["type"][$part->type] . "/" . strtolower($part->subtype);
$message["subtype"][$i] = strtolower($part->subtype);
$ext=$part->subtype;
$params = $part->dparameters;
$filename=$part->dparameters[0]->value;
// De orginele naam van de bijlage behouden
$orgbijlages .= $parts[$i]->dparameters[0]->value . ' , ';
// Een unieke naam maken voor de bijlage, zodat deze niet overschreden kan worden.
$Tijdelijkebijlage = date('Ymd') . '-' . uniqid() . '.' . substr($parts[$i]->dparameters[0]->value, -3);
$mege="";
$data="";
$mege = imap_fetchbody($mbox,$I,$fpos);
$filename="./bijlages/" . $Tijdelijkebijlage;
$fp=fopen($filename,w);
$data=getdecodevalue($mege,$part->type);
fputs($fp,$data);
fclose($fp);
$fpos+=1;
$tmpbijlages .= $Tijdelijkebijlage . ' , ';
}
}
}
?>
Om geen nieuw topic aan te maken, ga ik in dit topic van mij weer verder. Ik zit namelijk weer met hetzelfde.
Ik doe hetvolgende:
Code (php)
Dit geeft de volgende code:
Code (php)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
stdClass Object
(
[type] => 1
[encoding] => 0
[ifsubtype] => 1
[subtype] => MIXED
[ifdescription] => 0
[ifid] => 0
[bytes] => 6741876
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => BOUNDARY
[value] => ----_=_NextPart_001_01CA8EDA.3340A19B
)
)
[parts] => Array
(
[0] => stdClass Object
(
[type] => 1
[encoding] => 0
[ifsubtype] => 1
[subtype] => ALTERNATIVE
[ifdescription] => 0
[ifid] => 0
[bytes] => 3352
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => BOUNDARY
[value] => ----_=_NextPart_002_01CA8EDA.3340A19B
)
)
[parts] => Array
(
[0] => stdClass Object
(
[type] => 0
[encoding] => 4
[ifsubtype] => 1
[subtype] => PLAIN
[ifdescription] => 0
[ifid] => 0
[lines] => 14
[bytes] => 254
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => CHARSET
[value] => iso-8859-1
)
)
)
[1] => stdClass Object
(
[type] => 0
[encoding] => 4
[ifsubtype] => 1
[subtype] => HTML
[ifdescription] => 0
[ifid] => 0
[lines] => 94
[bytes] => 2774
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => CHARSET
[value] => iso-8859-1
)
)
)
)
)
[1] => stdClass Object
(
[type] => 2
[encoding] => 0
[ifsubtype] => 1
[subtype] => RFC822
[ifdescription] => 0
[ifid] => 0
[lines] => 86430
[bytes] => 6738191
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 0
[parameters] => stdClass Object
(
)
[parts] => Array
(
[0] => stdClass Object
(
[type] => 1
[encoding] => 0
[ifsubtype] => 1
[subtype] => MIXED
[ifdescription] => 0
[ifid] => 0
[bytes] => 6736609
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => BOUNDARY
[value] => ----_=_NextPart_003_01CA8C9A.E3E88880
)
)
[parts] => Array
(
[0] => stdClass Object
(
[type] => 1
[encoding] => 0
[ifsubtype] => 1
[subtype] => ALTERNATIVE
[ifdescription] => 0
[ifid] => 0
[bytes] => 748
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => BOUNDARY
[value] => ----_=_NextPart_004_01CA8C9A.E3E88880
)
)
[parts] => Array
(
[0] => stdClass Object
(
[type] => 0
[encoding] => 4
[ifsubtype] => 1
[subtype] => PLAIN
[ifdescription] => 0
[ifid] => 0
[lines] => 2
[bytes] => 10
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => CHARSET
[value] => iso-8859-1
)
)
)
[1] => stdClass Object
(
[type] => 0
[encoding] => 4
[ifsubtype] => 1
[subtype] => HTML
[ifdescription] => 0
[ifid] => 0
[lines] => 18
[bytes] => 414
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => CHARSET
[value] => iso-8859-1
)
)
)
)
)
[1] => stdClass Object
(
[type] => 5
[encoding] => 3
[ifsubtype] => 1
[subtype] => JPEG
[ifdescription] => 1
[description] => IMG_5558.JPG
[ifid] => 0
[bytes] => 3304356
[ifdisposition] => 1
[disposition] => INLINE
[ifdparameters] => 1
[dparameters] => Array
(
[0] => stdClass Object
(
[attribute] => FILENAME
[value] => IMG_5558.JPG
)
)
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => NAME
[value] => IMG_5558.JPG
)
)
)
[2] => stdClass Object
(
[type] => 5
[encoding] => 3
[ifsubtype] => 1
[subtype] => JPEG
[ifdescription] => 1
[description] => IMG_5557.JPG
[ifid] => 0
[bytes] => 3430840
[ifdisposition] => 1
[disposition] => INLINE
[ifdparameters] => 1
[dparameters] => Array
(
[0] => stdClass Object
(
[attribute] => FILENAME
[value] => IMG_5557.JPG
)
)
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => NAME
[value] => IMG_5557.JPG
)
)
)
)
)
)
)
)
)
(
[type] => 1
[encoding] => 0
[ifsubtype] => 1
[subtype] => MIXED
[ifdescription] => 0
[ifid] => 0
[bytes] => 6741876
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => BOUNDARY
[value] => ----_=_NextPart_001_01CA8EDA.3340A19B
)
)
[parts] => Array
(
[0] => stdClass Object
(
[type] => 1
[encoding] => 0
[ifsubtype] => 1
[subtype] => ALTERNATIVE
[ifdescription] => 0
[ifid] => 0
[bytes] => 3352
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => BOUNDARY
[value] => ----_=_NextPart_002_01CA8EDA.3340A19B
)
)
[parts] => Array
(
[0] => stdClass Object
(
[type] => 0
[encoding] => 4
[ifsubtype] => 1
[subtype] => PLAIN
[ifdescription] => 0
[ifid] => 0
[lines] => 14
[bytes] => 254
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => CHARSET
[value] => iso-8859-1
)
)
)
[1] => stdClass Object
(
[type] => 0
[encoding] => 4
[ifsubtype] => 1
[subtype] => HTML
[ifdescription] => 0
[ifid] => 0
[lines] => 94
[bytes] => 2774
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => CHARSET
[value] => iso-8859-1
)
)
)
)
)
[1] => stdClass Object
(
[type] => 2
[encoding] => 0
[ifsubtype] => 1
[subtype] => RFC822
[ifdescription] => 0
[ifid] => 0
[lines] => 86430
[bytes] => 6738191
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 0
[parameters] => stdClass Object
(
)
[parts] => Array
(
[0] => stdClass Object
(
[type] => 1
[encoding] => 0
[ifsubtype] => 1
[subtype] => MIXED
[ifdescription] => 0
[ifid] => 0
[bytes] => 6736609
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => BOUNDARY
[value] => ----_=_NextPart_003_01CA8C9A.E3E88880
)
)
[parts] => Array
(
[0] => stdClass Object
(
[type] => 1
[encoding] => 0
[ifsubtype] => 1
[subtype] => ALTERNATIVE
[ifdescription] => 0
[ifid] => 0
[bytes] => 748
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => BOUNDARY
[value] => ----_=_NextPart_004_01CA8C9A.E3E88880
)
)
[parts] => Array
(
[0] => stdClass Object
(
[type] => 0
[encoding] => 4
[ifsubtype] => 1
[subtype] => PLAIN
[ifdescription] => 0
[ifid] => 0
[lines] => 2
[bytes] => 10
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => CHARSET
[value] => iso-8859-1
)
)
)
[1] => stdClass Object
(
[type] => 0
[encoding] => 4
[ifsubtype] => 1
[subtype] => HTML
[ifdescription] => 0
[ifid] => 0
[lines] => 18
[bytes] => 414
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => CHARSET
[value] => iso-8859-1
)
)
)
)
)
[1] => stdClass Object
(
[type] => 5
[encoding] => 3
[ifsubtype] => 1
[subtype] => JPEG
[ifdescription] => 1
[description] => IMG_5558.JPG
[ifid] => 0
[bytes] => 3304356
[ifdisposition] => 1
[disposition] => INLINE
[ifdparameters] => 1
[dparameters] => Array
(
[0] => stdClass Object
(
[attribute] => FILENAME
[value] => IMG_5558.JPG
)
)
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => NAME
[value] => IMG_5558.JPG
)
)
)
[2] => stdClass Object
(
[type] => 5
[encoding] => 3
[ifsubtype] => 1
[subtype] => JPEG
[ifdescription] => 1
[description] => IMG_5557.JPG
[ifid] => 0
[bytes] => 3430840
[ifdisposition] => 1
[disposition] => INLINE
[ifdparameters] => 1
[dparameters] => Array
(
[0] => stdClass Object
(
[attribute] => FILENAME
[value] => IMG_5557.JPG
)
)
[ifparameters] => 1
[parameters] => Array
(
[0] => stdClass Object
(
[attribute] => NAME
[value] => IMG_5557.JPG
)
)
)
)
)
)
)
)
)
Met de code in mijn vorige post van 11.11.2009 13:27, geef ik aan dat ik bijlages kan downloaden. Dit gaat ook goed, tot dat ik een mail binnen krijg die weer doorgestuurd is.
Ik bedoel dan ik heb een mail die stuur ik als bijlage door (geen eml). Daar zitten 2 bijlages in, volgens de code hierboven dus: IMG_5558.JPG en IMG_5557.JPG dat klopt ook. Maar deze krijg ik niet gedownload naar me server.
Ik heb de volgende code nog toegevoegd, hij maakt nu wel een bestand aan in de map bijlages, alleen wordt er verder niks op geslagen. Dit komt omdat er bij $mege alles inzit, ipv alleen IMG_5558.JPG. Met alles bedoel ik de bijlage die in de eerste mail zit.
Heb dus een mail van pietje, in de mail van pietje zit de bijlage klaasje, de bijlage klaasje is een mail en in die mail zitten 2 bijlages (IMG_5558.JPG en IMG_5557.JPG).
Code (php)
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
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
<?php
for($s=1;$s<count($parts[$i]->parts[0]->parts);$s++)
{
if($parts[$i]->parts[0]->parts[$s]->disposition == 'ATTACHMENT' || $parts[$i]->parts[0]->parts[$s]->disposition == 'INLINE')
{
if(substr($parts[$i]->parts[0]->parts[$s]->dparameters[0]->value, -3) != 'exe' && substr($parts[$i]->parts[0]->parts[$s]->dparameters[0]->value, -3) != 'pif' && substr($parts[$i]->parts[0]->parts[$s]->dparameters[0]->value, -3) != 'vbs')
{
$message["type"][$i] = $message["attachment"]["type"][$parts[$i]->parts[0]->parts[$s]->type] . "/" . strtolower($parts[$i]->parts[0]->parts[$s]->subtype);
$message["subtype"][$i] = strtolower($parts[$i]->parts[0]->parts[$s]->subtype);
$ext=$parts[$i]->parts[0]->parts[$s]->subtype;
$params = $parts[$i]->parts[0]->parts[$s]->dparameters;
$filename=$parts[$i]->parts[0]->parts[$s]->dparameters[0]->value;
// De orginele naam van de bijlage behouden
if($orgbijlages == '')
{
$orgbijlages = $parts[$i]->parts[0]->parts[$s]->dparameters[0]->value;
}
else
{
$orgbijlages .= ',' . $parts[$i]->parts[0]->parts[$s]->dparameters[0]->value;
} //$orgbijlages .= $parts[$i]->parts[0]->parts[$s]->dparameters[0]->value . ' , ';
// Een unieke naam maken voor de bijlage, zodat deze niet overschreden kan worden.
$Tijdelijkebijlage = date('Ymd') . '-' . uniqid() . '.' . substr($parts[$i]->parts[0]->parts[$s]->dparameters[0]->value, -3);
$mege="";
$data="";
$mege = imap_fetchbody($mbox,$I,$fpos);
$filename="./bijlages/" . $Tijdelijkebijlage;
$fp=fopen($filename,w);
$data=getdecodevalue($mege,$parts[$i]->parts[0]->parts[$s]->type);
fputs($fp,$data);
fclose($fp);
$fpos+=1;
if($tmpbijlages == '')
{
$orgbijlages = $Tijdelijkebijlage;
}
else
{
$tmpbijlages .= ',' . $Tijdelijkebijlage;
}
}
}
}
?>
for($s=1;$s<count($parts[$i]->parts[0]->parts);$s++)
{
if($parts[$i]->parts[0]->parts[$s]->disposition == 'ATTACHMENT' || $parts[$i]->parts[0]->parts[$s]->disposition == 'INLINE')
{
if(substr($parts[$i]->parts[0]->parts[$s]->dparameters[0]->value, -3) != 'exe' && substr($parts[$i]->parts[0]->parts[$s]->dparameters[0]->value, -3) != 'pif' && substr($parts[$i]->parts[0]->parts[$s]->dparameters[0]->value, -3) != 'vbs')
{
$message["type"][$i] = $message["attachment"]["type"][$parts[$i]->parts[0]->parts[$s]->type] . "/" . strtolower($parts[$i]->parts[0]->parts[$s]->subtype);
$message["subtype"][$i] = strtolower($parts[$i]->parts[0]->parts[$s]->subtype);
$ext=$parts[$i]->parts[0]->parts[$s]->subtype;
$params = $parts[$i]->parts[0]->parts[$s]->dparameters;
$filename=$parts[$i]->parts[0]->parts[$s]->dparameters[0]->value;
// De orginele naam van de bijlage behouden
if($orgbijlages == '')
{
$orgbijlages = $parts[$i]->parts[0]->parts[$s]->dparameters[0]->value;
}
else
{
$orgbijlages .= ',' . $parts[$i]->parts[0]->parts[$s]->dparameters[0]->value;
} //$orgbijlages .= $parts[$i]->parts[0]->parts[$s]->dparameters[0]->value . ' , ';
// Een unieke naam maken voor de bijlage, zodat deze niet overschreden kan worden.
$Tijdelijkebijlage = date('Ymd') . '-' . uniqid() . '.' . substr($parts[$i]->parts[0]->parts[$s]->dparameters[0]->value, -3);
$mege="";
$data="";
$mege = imap_fetchbody($mbox,$I,$fpos);
$filename="./bijlages/" . $Tijdelijkebijlage;
$fp=fopen($filename,w);
$data=getdecodevalue($mege,$parts[$i]->parts[0]->parts[$s]->type);
fputs($fp,$data);
fclose($fp);
$fpos+=1;
if($tmpbijlages == '')
{
$orgbijlages = $Tijdelijkebijlage;
}
else
{
$tmpbijlages .= ',' . $Tijdelijkebijlage;
}
}
}
}
?>
Heeft iemand enige idee hoe ik dit kan oplossen?
Hoop dat ik het goed heb uitgelegd.
Alvast bedankt!
EDIT: verder heb ik nog gekeken naar http://www.phphulp.nl/php/scripts/4/1356/ maar ook hier wordt alleen een bestand aangemaakt, zonder inhoud.
Gewijzigd op 01/01/1970 01:00:00 door kitty N