in reply to net::pop3 usage

use the list method.

From the cookbook (slightly modified):
%msgs= $pop->list(); for $msg (keys %msgs) { print "the message $msg is $msgs{$msg} bytes long.\n"; $msgnum++; } print "\nthere is $msgnum messages\n"

Replies are listed 'Best First'.
Re: Re: net::pop3 usage
by LiTinOveWeedle (Scribe) on Mar 07, 2001 at 16:11 UTC
    Many THX but this was "last()" method not "list"....

    from doc... last() - Returns the highest MSGNUM of all the messages accessed. So how can return me 0 value if I have 2 mails in my box?

    And "top(MSGNUM) return should return me:

    from doc Get the header and the first NUMLINES of the body for the message MSGNUM. Returns a reference to an array which contains the lines of text read from the server.

    but when I try to acess array by @$ notation nothing happend. I will look at cook book for some more info, but if you know why this happened.... THX. Litin

      Isn't last() supposed to gives you the highest MSGNUM of your accessed messages ?
Re: Re: net::pop3 usage
by LiTinOveWeedle (Scribe) on Mar 07, 2001 at 16:37 UTC
    I am sorry I tried this and get only

    Starting script
    conecting to POP3 server....
    Conected.
    Receiving mails...
    the message HASH(0x1b4440c) is bytes long.
    there is 1 messages
    Done.

    This was only one what I get from your code... Login is correct I checking it on my local instlation of mail server:

    Wed 2001-03-07 12:22:29: 60:8 Accepting POP connection from 10.0.0.75
    Wed 2001-03-07 12:22:29: 60:8 +OK xxx.cz POP MDaemon ready using UNREGISTERED SOFTWARE 3.5.4
    Wed 2001-03-07 12:22:29: 60:8 USER xxxxxx
    Wed 2001-03-07 12:22:29: 60:8 +OK xxxxx... Recipient ok
    Wed 2001-03-07 12:22:29: 60:8 PASS ******
    Wed 2001-03-07 12:22:29: 60:8 +OK xxxxx@xxxxx.cz's mailbox has 2 total messages (20354 octets).
    Wed 2001-03-07 12:22:29: 60:8 STAT
    Wed 2001-03-07 12:22:29: 60:8 +OK 2 20354
    Wed 2001-03-07 12:22:29: 60:8 LAST
    Wed 2001-03-07 12:22:29: 60:8 +OK 0
    Wed 2001-03-07 12:22:29: 60:8 LIST
    Wed 2001-03-07 12:22:29: 60:8 +OK 2 20354
    Wed 2001-03-07 12:22:29: 60:8 1 18831
    Wed 2001-03-07 12:22:29: 60:8 2 1523
    Wed 2001-03-07 12:22:29: 60:8 .
    Wed 2001-03-07 12:22:29: 60:8 QUIT
    Wed 2001-03-07 12:22:29: 60:8 +OK xxxxx@xxxxx.cz xxxxx.cz POP Server signing off (2 messages left)
    Wed 2001-03-07 12:22:29: 60:8 POP session complete, 0 bytes transferred!

    But as you can see scripts list mail corectly but code cannot take results. Debbuger message:

    Reference found where even-sized list expected at c:\windows\TEMP\DzTemp.pl line 53.
    Use of uninitialized value in concatenation (.) at c:\windows\TEMP\DzTemp.pl line 55.

      From the errors your getting, it looks like list() returns a hash-ref, not a list. Change the first line of arhuman's code to: %msgs = %{$pop->list()};

      and it should work.

      HTH

      bbfu
      Seasons don't fear The Reaper.
      Nor do the wind, the sun, and the rain.
      We can be like they are.

        Thank you this is working very well :-)))) but I have another question please. Methods from Net:Pop3 returns as results true or false meaning that operation was succes or not. But how to do something like this

        unless ( $mail_count = $pop->login( $username, $password ) ) {
        return 0;
        }

        This return to $mail_count number of mails. If there is 0 mails in pop3 box procedure end. But I want terminate procedure if method login will not be succesful. How should I do this?

        Please, if you know, help me. Litin