Read the files

Read the files from the folder one by one and send the email and copy the files to another folder named ‘archive’.

 if($contents) {
   foreach ($contents as $file) {
        if(strpos($file, '.') !== (int) 0) {
            sendMailAsAttachment( $file , $path);
            copyPlaceholderFileToArchived( $file, $path , $destination );
        }
    }
   }

Share this Tutorial