DOKK / manpages / debian 12 / libsisimai-perl / Sisimai::Mail::Mbox.3pm.en
Sisimai::Mail::Mbox(3pm) User Contributed Perl Documentation Sisimai::Mail::Mbox(3pm)

Sisimai::Mail::Mbox - Mailbox reader

    use Sisimai::Mail::Mbox;
    my $mailbox = Sisimai::Mail::Mbox->new('/var/spool/mail/root');
    while( my $r = $mailbox->read ) {
        print $r;   # print contents of each mail in mbox
    }

Sisimai::Mail::Mbox is a mailbox file (UNIX mbox) reader.

"new(path to mbox)"

"new()" is a constructor of Sisimai::Mail::Mbox

    my $mailbox = Sisimai::Mail::Mbox->new('/var/mail/root');

"dir()" returns the directory name of mbox

    print $mailbox->dir;   # /var/mail

"path()" returns the path to mbox.

    print $mailbox->path;   # /var/mail/root

"file()" returns a file name of the mbox.

    print $mailbox->file;   # root

"size()" returns the file size of the mbox.

    print $mailbox->size;   # 94515

"offset()" returns offset position for seeking the mbox. The value of "offset" is bytes which have already read.

    print $mailbox->offset;   # 0

"handle()" returns file handle object (IO::File) of the mbox.

    $mailbox->handle->close;

"read()" works as a iterator for reading each email in the mbox.

    my $mailbox = Sisimai::Mail->new('/var/mail/neko');
    while( my $r = $mailbox->read ) {
        print $r;   # print each email in /var/mail/neko
    }

azumakuniyuki

Copyright (C) 2014-2016,2018,2019 azumakuniyuki, All rights reserved.

This software is distributed under The BSD 2-Clause License.

2022-12-23 perl v5.36.0