The Little Guy Posted September 1, 2008 Share Posted September 1, 2008 How do I get these: 1. Body Text 2. The Attachment(s) Here is what I have to get an attachment, but it doesn't work at all: $info = imap_fetchstructure($imap, $msg); $numparts = count($info->parts); $attachment = ''; if ($numparts > 1) { foreach ($info->parts as $part) { if ($part->disposition == "ATTACHMENT") { $attachment .= $part->dparameters[0]->value; } } } I am able to read an email without an attachment, but not an email with an attachment. more code: $mbox = imap_open("{mail.dudeel.com/novalidate-cert}", "[email protected]", "xxxxxxx")or die(); $dir = 1; $smail = imap_sort($mbox,SORTDATE,$dir); if($smail){ foreach($smail as $msg){ if(count($smail) > 0){ $body = imap_fetchbody($mbox, $msg, "2"); $headers = imap_headerinfo($mbox,$msg); if(empty($headers->subject)){ $subject = "(No Subject)"; }else{ $subject = $headers->subject; } $to = $headers->to[0]->mailbox.'@'.$headers->to[0]->host; $personal = $headers->from[0]->personal; $from = $headers->reply_to[0]->mailbox.'@'.$headers->reply_to[0]->host; $info = imap_fetchstructure($imap, $msg); $numparts = count($info->parts); $attachment = ''; if ($numparts > 1) { foreach ($info->parts as $part) { if ($part->disposition == "ATTACHMENT") { $attachment .= $part->dparameters[0]->value; } } } } } } Link to comment https://forums.phpfreaks.com/topic/122188-imap-file-attachments/ Share on other sites More sharing options...
The Little Guy Posted September 1, 2008 Author Share Posted September 1, 2008 Boink Link to comment https://forums.phpfreaks.com/topic/122188-imap-file-attachments/#findComment-631157 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.