For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > February 2005 > problem in downoading file using get( ) of POP3









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author problem in downoading file using get( ) of POP3
Girish Kelwalkar

2005-02-23, 3:55 pm

_

hello experts,

I am writing one code which detect new coming mails from
server and download it to file. I am showing you the portion
of code.

1 for($l=1;$l<=$msg_id;$l++)
2 {
3 my $MsgContent = $pop3->top($l, 20);
4 open (CHECK, ">msgtext$l.txt") || die ("sorry");
5 $pop3->get($l,*CHECK);
6 close (CHECK);
8 }

Where $msg_id is no. of new incoming mails for me.
$pop3 is instance of mailserver created using Net::POP3.
Now problem is that when loop will execute first time
it is creating msgtext1.txt containg mail message but
when second onwards loop will execute, its just creating
empty files like msgtext2.txt, msgtext3.txt and so on.
I can not identify the problem. Can anybody plz give
me solution over this.

Thnx in advance...



Wiggins d'Anconia

2005-02-23, 3:55 pm

girish kelwalkar wrote:
>
>
> hello experts,
>
> I am writing one code which detect new coming mails from
> server and download it to file. I am showing you the portion
> of code.
>
> 1 for($l=1;$l<=$msg_id;$l++)
> 2 {
> 3 my $MsgContent = $pop3->top($l, 20);
> 4 open (CHECK, ">msgtext$l.txt") || die ("sorry");
> 5 $pop3->get($l,*CHECK);


In the above you should test for a true/false return value to see if
there is an error occurring. In the case that there is, it should be
retrievable with:

$pop3->message; # (see Net::Cmd for more)

> 6 close (CHECK);
> 8 }
>
> Where $msg_id is no. of new incoming mails for me.
> $pop3 is instance of mailserver created using Net::POP3.
> Now problem is that when loop will execute first time
> it is creating msgtext1.txt containg mail message but
> when second onwards loop will execute, its just creating
> empty files like msgtext2.txt, msgtext3.txt and so on.
> I can not identify the problem. Can anybody plz give
> me solution over this.
>


You should turn on the 'Debug' flag during object construction and see
if the output provides any clues. You might also check the POP3 server
logs to determine if any error messages are being output on that side.
It appears the 'top' method is optional for the server.

> Thnx in advance...
>


A cursory glance at the docs doesn't turn up anything immediately wrong
in the snippet you provided above. Do mesgs >1 get returned if you save
them directly to a variable??

http://danconia.org
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com