in reply to Sendmail .forward + perl
open(MAIL, ">/home/brian/mail.txt");if you want a spool file (list of all messages), you'd need to open the file handle for appending:
open(MAIL, ">>/home/brian/mail.txt");While you're at it, you should probably lock the file while you are writing to it, so the next piece of inbound mail doesn't try to screw with your mail.txt file while you are already writing to it.
(this code is ripped from OraPP2ndEd, p 166-7)
flock MAIL, 2;
seek MAIL, 0, 2; # skip to the end for spooling
while (<STDIN>) {print MAIL $_;}
flock MAIL, 8;
close MAIL || die($!);
Note that flock can't be tested with die, since it waits
until the file is "freed up" for locking. If your system
doesn't implement flock, you'll get a fatal runtime error,
AFAIK
|
|---|