Bytor_47 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to acces my mail box using the Mail::Box module but get the following error message:

ERROR: Cannot get a lock on Mail::Box::Mbox folder /var/mail/username.
WARNING: Folder does not exist, failed opening mbox folder /var/mail/username.

I am just starting this script and only have the following lines of code so far:
use Mail::Box::Manager; my $mgr = Mail::Box::Manager->new; my $folder = $mgr->open(folder => $ENV{MAIL});
How can I get a lock on the file?

Is there a way to get Mail::MboxParser to delete mail?   I can read the mail with that but I would like to delete the mail once I am done with it.

Thanks in advance.

janitored by ybiC: Minor format cleanup, including balanced <code> tags around snippet and linkify mentions of CPAN modules

Replies are listed 'Best First'.
Re: Need help with Mail::Box module please
by gam3 (Curate) on Apr 26, 2005 at 02:39 UTC
    By default Mail::Box tries to create a /var/mail/username.lock file and you don't have the permissions required to do that. You can set lock_file to something else, but you need to know what locking your MTA is using or you might loose mail.

    One thing you can do is Move the mail file to your home directory. Make sure the move is atomic. That will also solve your delete problem, as the MTA will recreate the mailbox nextime you get mail.

    -- gam3
    A picture is worth a thousand words, but takes 200K.