Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Error in Net::POP3

by bulrush (Scribe)
on Jul 01, 2014 at 11:28 UTC ( [id://1091828]=perlquestion: print w/replies, xml ) Need Help??

bulrush has asked for the wisdom of the Perl Monks concerning the following question:

Perl 5.8.8 on Linux RHEL 5.5.56

Basically my Perl program has to read all emails in a POP3 mailbox, and save all attachments to a hardcoded subdir, process them with a Perl program, and send an SMTP email out telling the user of success or failure (SMTP part works). But I also need plain authentication no SSL or TLS. I do care about the message body, because the same email address may have to be used for multiple Perl programs (from multiple inputs/departments), so I may have to process the body looking for commands I define, to tell me which program to run no the attached file.

I just installed Net::POP3 2.31 on Jun 30. I can retrieve my first message from my email account fine, when I get to the second message (message number 2) I get this error in the get() method:

main::getnetpop3(conv.pl:627):      $msgsize=$conn->list($msgnum); # Get one msg size, in bytes?
  DB<8> n                                                                                    
Use of uninitialized value in numeric eq (==) at /usr/lib/perl5/5.8.8/Net/POP3.pm line 311.
at /usr/lib/perl5/5.8.8/Net/POP3.pm line 311
        Net::POP3::_LIST('Net::POP3=GLOB(0xa99bb50)', 2) called at /usr/lib/perl5/5.8.8/Net/POP3.pm line 202
        Net::POP3::list('Net::POP3=GLOB(0xa99bb50)', 2) called at conv.pl line 627
        main::getnetpop3() called at conv.pl line 164
main::getnetpop3(conv.pl:628):      $headers=$conn->top($msgnum); # Returns ref to array.

I'm not familiar with this module nor do I do module programming. Basically I cannot get any msg but the first.

Anyone know how to fix the error?

I'll try to contact the author but the last copyright date is 2003. His email address may not be valid: Graham Barr <gbarr@pobox.com>

Thanks.

P.S. If you have another good example of accessing a POP3 email account and saving attachments (XLS files) then I can try that. But I'm still new to doing POP3 via Perl so a clear example is what I'm looking for. I tend to learn by looking at the full code. I do need a POP3 module that supports auth though, but not SSL or TSL.

Replies are listed 'Best First'.
Re: Error in Net::POP3
by AppleFritter (Vicar) on Jul 01, 2014 at 12:19 UTC

    I cannot help you with Net::POP3, but have you looked into Mail::Box::POP3? The Mail::Box bundle is actively being developed - the last release happened a little over a month ago -, and a quick glance suggests it supports authentication without forcing SSL/TLS.

    That said, I'm not familiar with it and can't vouch for it, much less guarantee it will work on Perl 5.8 (which is really fairly old by now).

      I'm looking at Mail::Box right now. It looks more updated, Updated in 2014. Thanks!
      Perl 5.8.8 on Redhat Linux RHEL 5.5.56 (64-bit)
      I'm looking/Googling for some simple code to show me the minimum I need to log in, get a msg, save an attachment.

      Perl 5.8.8 on Redhat Linux RHEL 5.5.56 (64-bit)

        Answers to questions are free, consultant work ("code this for me") costs extra. ;)

        That said -- did you look at Mail::Box-Cookbook? The author's website also has various pieces of documentation, including tutorial slides from past workshops.

      I'm pretty new at Perl email and Object Oriented Perl but I'm not seeing how to save an attached XLS file from a POP3 message. So that's probably why I didn't use Mail::Box::POP3, as I can't find many good coding examples of saving an attachment.

      A Google search did not give me many complete examples. If you have a more complete example I'd appreciate a link to it.

      Perl 5.8.8 on Redhat Linux RHEL 5.5.56 (64-bit)

        Disclaimer: I don't have any setup for testing any of this with, but here's some skeleton code:

        use Mail::Box::POP3; my $folder = Mail::Box::POP3->new(folder => $ENV{MAIL}, ...); my $message = $folder->message(0); if($message->body->isMultipart) { foreach my $part ($message->body->parts) { my $attached_body = $part->decoded; ... } }

        This is based on pieces of code found throughout the (admittedly ascetic) Mail::Box documention.

Re: Error in Net::POP3
by mr_mischief (Monsignor) on Jul 01, 2014 at 13:38 UTC

    Has it occurred to you that the POP3 protocol hasn't changed in the last eleven years?

    What code are you using that generates this error? How much does it resemble the example code at https://metacpan.org/pod/Net::POP3?

    Did you read How do I post a question effectively? which should have been linked to from the page where you entered your "bug report"?

Re: Error in Net::POP3
by InfiniteSilence (Curate) on Jul 01, 2014 at 15:00 UTC

    Please include some script code where you are calling Net::POP3...namely this entry point:

    ... main::getnetpop3() called at conv.pl line 164 ...

    Celebrate Intellectual Diversity

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1091828]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-18 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found