MailFolder
view release on metacpan or search on metacpan
Mail/Folder/Emaul.pm view on Meta::CPAN
return $href;
}
=head2 append_message($mref)
Calls the superclass C<append_message> method.
Returns C<0> if it cannot lock the folder.
Appends the contents of the mail message contained C<$mref> to
the the folder.
It also caches the header.
Please note that, contrary to other documentation for B<Mail::Folder>,
the Emaul C<append_message> method actually updates the real folder,
rather than queueing it up for a subsequent sync. The C<dup> and
C<refile> methods are also affected. This will be fixed soon.
=cut
sub append_message {
my $self = shift;
my $mref = shift;
my $dup_mref = $mref->dup;
my $msgnum = $self->last_message;
return 0 unless $self->SUPER::append_message($dup_mref);
return 0 unless $self->_lock_folder;
$msgnum++;
$dup_mref->delete('From ');
_write_message($self->foldername, $msgnum, $dup_mref);
$self->_unlock_folder;
$self->remember_message($msgnum);
$self->cache_header($msgnum, $dup_mref->head);
return 1;
}
=head2 update_message($msg_number, $mref)
Calls the superclass C<update_message> method.
It returns C<0> if it cannot lock the folder.
Replaces the message pointed to by C<$msg_number> with the contents of
the C<Mail::Internet> object reference C<$mref>.
Please note that, contrary to other documentation for B<Mail::Folder>,
the Emaul C<update_message> method actually updates the real folder,
rather than queueing it up for a subsequent sync. This will be fixed
soon.
=cut
sub update_message {
my $self = shift;
my $key = shift;
my $mref = shift;
my $dup_mref = $mref->dup;
$dup_mref->delete('From ');
return 0 unless $self->SUPER::update_message($key, $dup_mref);
return 0 unless $self->_lock_folder;
_write_message($self->foldername, $key, $dup_mref);
$self->_unlock_folder;
return 1;
}
=head2 is_valid_folder_format($foldername)
Returns C<0> if the folder is not a directory or looks like a maildir
folder. The current logic allows it to handle MH directories, but
watch out; you should probably set the C<NotMUA> option so the
interface doesn't create it's own little folder droppings like
C<.msg_labels> and such.
=cut
sub is_valid_folder_format {
my $foldername = shift;
return 0 unless (-d $foldername);
return 0 if (-d "$foldername/tmp" &&
-d "$foldername/cur" &&
-d "$foldername/new"); # make sure it isn't a maildir folder
return 1 if (-f "$foldername/.current_msg");
return 1; # NOTE: this is a leap of faith - if there's
# ever an MH interface, this will have to be
# tweaked...
}
=head2 create($foldername)
Returns C<0> if the folder already exists.
Creates a new folder named C<$foldername> with mode C<0700> and then
returns C<1>.
=cut
sub create {
my $self = shift;
my $foldername = shift;
return 0 if (-e $foldername);
mkdir($foldername, 0700) or croak "can't create $foldername: $!";
return 1;
( run in 2.392 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )