Rottingham Posted June 30, 2009 Share Posted June 30, 2009 Hello all, I did search the forum for this and didn't see it. I'm writing a small script to look in the mail directory of my server and open any files in /new subdir to parse. I am using the following code and get the file name to print out, but fopen() fails to open it. Any help would be appreciated! $mail_directory = "/home/innovba0/mail/mydomain.com/newsletter/new"; if( is_dir( $mail_directory ) ) { if( $dir = opendir( $mail_directory) ) { while ( ( $file = readdir($dir) ) !== false ) { if( is_dir( $file ) ) continue; echo $file; $fh = fopen( $mail_directory . $file, "rb" ); if( $fh ) $f_buffer = fread( $fh, filesize( $mail_directory . $file ) ); echo $f_buffer."<br><br>"; } } } else echo "Not a directory."; It is echoing out the file name, which is usually something like: 1246326528.H85848P29127.box398.bluehost.com,S=26638 Link to comment https://forums.phpfreaks.com/topic/164184-open-mail-files-on-server/ Share on other sites More sharing options...
patrickmvi Posted June 30, 2009 Share Posted June 30, 2009 What is the error that fopen() is outputting when it fails to open it? We need to know the type of error in order to be able to resolve it. Most likely it has something to do with permissions. Link to comment https://forums.phpfreaks.com/topic/164184-open-mail-files-on-server/#findComment-866298 Share on other sites More sharing options...
Rottingham Posted June 30, 2009 Author Share Posted June 30, 2009 It generates a file not found error Warning: fopen(/home/innovba0/mail/mydomain.com/newsletter/new1246378302.H68109P18607.box398.bluehost.com,S=23817) [function.fopen]: failed to open stream: No such file or directory in /home/innovba0/public_html/admin/test.php on line 22 Link to comment https://forums.phpfreaks.com/topic/164184-open-mail-files-on-server/#findComment-866477 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.