Net::POP3::PerMsgHandler - subroutine for per message from POP3 server
Quick summary of what the module does.
Perhaps a little code snippet.
use Net::POP3::PerMsgHandler; use YAML::Syck; use Perl6::Say; my $cfg = LoadFile('config.yml'); eval { my $count = per_message( username => $cfg->{username}, password => $cfg->{password}, host => $cfg->{host}, handler => sub { my ($msg, $ctl) = @_; my $email = $msg->email_mime; # Email::MIME object. say "Subject: ".$email->header('Subject'); $ctl->delete(0) # default $ctl->quit(0) # default }, ); }; say $@ if $@; # connection failed etc... # Subject: Re: Spam collection # Subject: Congratulations, You're a finalist # Subject: Software Secret: WARNING Reading this could change your life # ...
required.
optional.
code reference required.
The callback is given two arguments. The first is a Net::POP3::PerMsgHandler::Message object. The second is a Net::POP3::PerMsgHandler::Control object.
Executes the callback for each message.
my $count = per_message( username => $cfg->{username}, password => $cfg->{password}, host => $cfg->{host}, handler => sub { my ($msg, $ctl) = @_; my $email = $msg->email_mime; my $is_spam = $email->header('Subject') =~ m/^SPAM/; $ctl->delete(1) if $is_spam; }, );
my $count = per_message( username => $cfg->{username}, password => $cfg->{password}, host => $cfg->{host}, handler => sub { my ($msg, $ctl) = @_; my $email = $msg->email_mime; return unless $email->body =~ m/\AUUID: 12345/sm; for my $part ($email->parts) { next unless defined $part->filename; $part->body > io( $part->filename ); } $ctl->delete(1); $ctl->quit(1); }, );
Net::POP3::PerMsgHandler, Net::POP3, Email::MIME, Email::MIME::Attachment::Stripper, Mail::Message, Mail::Message::Attachment::Stripper
bokutin, <bokutin at cpan.org>
<bokutin at cpan.org>
Copyright 2007 bokutin, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Net::POP3::PerMsgHandler, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::POP3::PerMsgHandler
CPAN shell
perl -MCPAN -e shell install Net::POP3::PerMsgHandler
For more information on module installation, please visit the detailed CPAN module installation guide.