NAME

Sisimai::Mail - Handler of Mbox/Maildir for reading each mail.

SYNOPSIS

use Sisimai::Mail;
my $mailbox = Sisimai::Mail->new('/var/mail/root');
while( my $r = $mailbox->read ) {
    print $r;
}

my $maildir = Sisimai::Mail->new('/home/neko/Maildir/cur');
while( my $r = $maildir->read ) {
    print $r;
}

my $mailtxt = 'From Mailer-Daemon ...';
my $mailobj = Sisimai::Mail->new(\$mailtxt);
while( my $r = $mailobj->read ) {
    print $r;
}

DESCRIPTION

Sisimai::Mail is a handler for reading a UNIX mbox, a Maildir, or any email message input from STDIN variable. It is a wrapper class of the following child classes:

* Sisimai::Mail::Mbox
* Sisimai::Mail::Maildir
* Sisimai::Mail::STDIN
* Sisimai::Mail::Memory

CLASS METHODS

new(path to mbox|Maildir/)

new() method is a constructor of Sisimai::Mail

my $mailbox = Sisimai::Mail->new('/var/mail/root');
my $maildir = Sisimai::Mail->new('/home/nyaa/Maildir/cur');
my $mailtxt = 'From Mailer-Daemon ...';
my $mailobj = Sisimai::Mail->new(\$mailtxt);

INSTANCE METHODS

path()

path() method returns the path to the mbox or the Maildir.

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

kind()

kind() method returns the name of the data type

print $mailbox->kind;   # mailbox or maildir, stdin, or memory.

mail()

mail() method returns the Sisimai::Mail::Mbox object or the Sisimai::Mail::Maildir object.

my $o = $mailbox->mail;
print ref $o;   # Sisimai::Mail::Mbox

read()

read() method works as an iterator for reading each email in the mbox or the Maildir. It calls Sisimai::Mail::Mbox-read()> or Sisimai::Mail::Maildir-read> methods.

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

AUTHOR

azumakuniyuki

COPYRIGHT

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

LICENSE

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