logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Sisimai::Mail::Memory - Mailbox reader

Author

       azumakuniyuki

Class Methods

"new(\$scalar)"
       new() method is a constructor of "Sisimai::Mail::Memory"

           my $mailtxt = 'From Mailer-Daemon ...';
           my $mailobj = Sisimai::Mail::Memory->new(\$mailtxt);

Description

       "Sisimai::Mail::Memory" is a class for reading a mailbox, files in Maildir/ from the value of the
       specified variable.

Instance Methods

"path()"
       path() method returns a fixed string ""<MEMORY"">

           print $mailbox->path;   # "<MEMORY>"

   "size()"
       size() method returns a memory size of the mailbox

           print $mailobj->size;   # 94515

   "payload()"
       payload() method returns an array reference to each email message

           print scalar $mailobj->payload->@*; # 17

   "offset()"
       offset() method returns the offset position for seeking "payload" list. The value of "offset" is an index
       number which have already read.

           print $mailobj->offset;   # 0

   "read()"
       read() method works as an iterator for reading each email in the mailbox.

           my $mailtxt = 'From Mailer-Daemon ...';
           my $mailobj = Sisimai::Mail->new(\$mailtxt);
           while( my $r = $mailobj->read ) {
               print $r;   # print each email in the first argument of new().
           }

License

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

perl v5.40.1                                       2025-04-12                         Sisimai::Mail::Memory(3pm)

Name

       Sisimai::Mail::Memory - Mailbox reader

Synopsis

           use Sisimai::Mail::Memory;
           my $mailtxt = 'From Mailer-Daemon ...';
           my $mailobj = Sisimai::Mail::Memory->new(\$mailtxt);
           while( my $r = $mailobj->read ) {
               print $r;   # print contents of each mail in the mailbox or Maildir/
           }

See Also