Php Code Wanted! Payin 10 Pt.

B

Brandon

Guest
I need a php script that when run emails a .txt file to me with a subject line of my choosing and than clears the .txt file of any text.
 

dsfreak

New Member
Messages
1,338
Reaction score
0
Points
0
You want it to email you the .txt file, then delete the .txt file, while at the same time know what the subject line should be? Basicly, an automated email form, like then one on phpBB?
 
B

Brandon

Guest
No. It emails me the .txt file with a subject line I want then clears out the .txt file to a blank one
 

dsfreak

New Member
Messages
1,338
Reaction score
0
Points
0
Ok. I got it now. I will try to make the PHP later tonight. Got chores now (damn). Will contact you later with the code.
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
Wow I made a few mistakes in that other post of mine. I meant "It's not that hard", and "I could do it in 10 lines or less".

PHP:
<?php

function readClearEmailFile($email, $filename) {

   if (is_readable($filename)) {
	  $content = file_get_contents($filename);
	      mail($email, "File Contents", $content) or die("Error sending email.");
	      $handle = fopen($filename, "w+");
	      fclose($handle);
    } else {
	  return $filename .' is not readable.';
    }
   return "File cleared, email sent successfully.";
}

?>

Make sure to chmod the file so it can be "read" by the script.
 
Last edited:
Top