meomike2000 Posted June 8, 2011 Share Posted June 8, 2011 workin on an email program and i need help with the attachments. were r the stored or how do i make a link to them for downloading, i have searched my email directory and can not find them..... any help would be great. thanks mike Link to comment https://forums.phpfreaks.com/topic/238828-need-help-with-email-attachments/ Share on other sites More sharing options...
spiderwell Posted June 8, 2011 Share Posted June 8, 2011 mike without knowing exactly what code you have, there isn't much anyone can suggest. how are you accessing the emails in the first place, I would imagine that whatever method you are using would have a way to access email properties including attachments, sorry not a great reply but you haven't given more than a vague description to respond to. Link to comment https://forums.phpfreaks.com/topic/238828-need-help-with-email-attachments/#findComment-1227172 Share on other sites More sharing options...
meomike2000 Posted June 8, 2011 Author Share Posted June 8, 2011 i use this sample: $structure = imap_fetchstructure($this->mail,$this->messId); if (!$structure->parts) { // not multipart $body = $this->getPart($s,0); }else { // multipart: iterate through each part $plainmsg = false; $htmlmsg = false; $attachment = Array(); foreach ($structure->parts as $partno0 => $p) { $piece = $this->getPart($p,$partno0+1); if ($piece['type'] == 'attachment') { $attachment[] = $piece['fileName']; //$body['attachment'] = $piece['fileName'];//$this->getPart($p,$partno0+1); }else{ if ($piece['type'] == 'plain') { $plainmsg = $this->formatMessage($piece['body']); } if ($piece['type'] == 'html') { $htmlmsg = $this->formatMessage($piece['body']); } } } if ($attachment) {$body['attachment'] = $attachment;} if ($plainmsg && $htmlmsg) { $body['body'] = ($this->userChoice == 'html') ? $htmlmsg : $plainmsg; //$body['body'] = $piece['type']; }else{ $body['body'] = ($htmlmsg) ? $htmlmsg : $plainmsg; //$data = ($partno > 0) ? imap_fetchbody($mbox,$mid,$partno) : imap_body($mbox,$mid); } } and the piece from $this->getPart($p,$partno0+1); that handles attachment...... // ATTACHMENT // Any part with a filename is an attachment, // so an attached text file (type 0) is not mistaken as the message. if ($params['filename'] || $params['name']) { // filename may be given as 'Filename' or 'Name' or both $filename = ($params['filename'] || $params['name']) ? $params['filename'] : $params['name']; $body['type'] = 'attachment';//$data; $body['fileName'] = $filename; $body['fileData'] = $data; } hope this helps Link to comment https://forums.phpfreaks.com/topic/238828-need-help-with-email-attachments/#findComment-1227185 Share on other sites More sharing options...
spiderwell Posted June 8, 2011 Share Posted June 8, 2011 This should help someone help you, I've not used imap in php sorry about that! Link to comment https://forums.phpfreaks.com/topic/238828-need-help-with-email-attachments/#findComment-1227199 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.