Jump to content

Open mail files on server


Rottingham

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.