Sisimai::Mail::Memory - Mailbox reader
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/ }
Sisimai::Mail::Memory is a class for reading a mailbox, files in Maildir/, or JSON string from variable.
new(\$scalar)
new() is a constructor of Sisimai::Mail::Memory
new()
my $mailtxt = 'From Mailer-Daemon ...'; my $mailobj = Sisimai::Mail::Memory->new(\$mailtxt);
size()
size() returns a memory size of the mailbox or JSON string.
print $mailobj->size; # 94515
data()
data() returns an array reference to each email message or JSON string
print scalar @{ $mailobj->data }; # 17
offset()
offset() returns an offset position for seeking "data". The value of "offset" is an index number which have already read.
print $mailobj->offset; # 0
read()
read() works as a 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(). }
azumakuniyuki
Copyright (C) 2018 azumakuniyuki, All rights reserved.
This software is distributed under The BSD 2-Clause License.
To install Sisimai, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sisimai
CPAN shell
perl -MCPAN -e shell install Sisimai
For more information on module installation, please visit the detailed CPAN module installation guide.