On Tuesday 11 December 2001 09:00 am, DigitalKoala wrote:
> What i want to do is then delete the contents of the file, but not the file
> itself...can you tell me the best way to do this?

Well, you can read the contents of the original file into a PHP variable 
using fopen().  Then, use something like ereg_replace to find what you're 
looking for and delete it (replace it with nothing) and the fwrite the file 
back out.  You'll also want to make sure you use flock() to lock the file 
prior to opening it.  Otherwise, you'll run into problems if your MTA tries 
to deliver another message at the same time.

Make sure you understand about unix file locking before you try this on a 
production mailbox -- you have to use the same method of file locking as your 
MTA uses.  Otherwise, Bad Things can happen. :)

Honestly, I'd say you'd be better off using something like procmail or even 
perl for this.  Procmail is designed to muck around with mail spool files and 
Perl is better suited for unix file handling and manipulation, IMO.

That said, I'm sure it can be done in PHP, so best of luck if you decide to 
go ahead with it.



PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to