IMAP :- How to download the attachment if any.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,
   
  I want to open a mssage using PHP ( IMAP ). How should I download the attachment if there is any with the email message.
   
  Please send me the code.
   
   
   
  <?php
   $imap = imap_open("{localhost/pop3}INBOX", "username", "password") or die("can't connect: ".imap_last_error());
   $message_count = imap_num_msg($imap);
echo "Total Messages :- ".$message_count;
echo "<br>";
   for ($i = 1; $i <= $message_count; ++$i) {
      $header = imap_header($imap, $i);
      //$body = trim(substr(imap_body($imap, $i), 0, 100));
   $body = imap_body($imap, $i);
      $prettydate = date("jS F Y", $header->udate);
        if (isset($header->from[0]->personal)) {
         $personal = $header->from[0]->personal;
      } else {
         $personal = $header->from[0]->mailbox;
      }
        $email = "$personal <{$header->from[0]->mailbox}@{$header->from[0]->host}>";
      echo "On $prettydate, $email said \"$body\".\n";
   }
     imap_close($imap);
?>

   
   

       
---------------------------------
 Try the revolutionary next-gen Yahoo! Mail. Click here.

[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux