title: how to download mails attachment to a specific folder using IMAP and php
body: <p>i am developing a site in which users can mail tickets and attach any type of files to a specific mail id. I need to add the mail subject, content and attachment to the database. I am doing this using cron. Except the attachments every thing works perfect. I have seen some post which create download links. Since i am using cron i can't do it manually.</p>
  
  <pre><code>        $hostname = '{xxxx.net:143/novalidate-cert}INBOX';
          $username = 'yyy@xxxx.net';
          $password = 'zzzz';
          /* try to connect */
          $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to : ' . imap_last_error());
          $emails = imap_search($inbox,'ALL');
  
                  if($emails) {
            $output = '';
            rsort($emails);
            foreach($emails as $email_number) {
              $structure = imap_fetchstructure($inbox, $email_number); 
              $name = $structure-&gt;parts[1]-&gt;dparameters[0]-&gt;value; // name of the file
              $type = $structure-&gt;parts[1]-&gt;type; //type of the file 
  }}
  </code></pre>
  
  <p>I am able to get type and name of the files but don't know how to proceed further</p>
  
  <p>Any one please help me. thank you...</p>