CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Net::POP3

 



MStates
Deleted

Feb 13, 2000, 11:53 AM

Post #1 of 6 (835 views)
Net::POP3 Can't Post

Can anyone tell me what might be wrong with this code? It works fine until I get to the login portion... then I get a 505.

code-----------------------------------------

use Net::POP3;

$user = "(my user name)";
pass = "(my password)";
$mailserver = "pop3.(my domain).com";

$pop3 = Net::POP3->new($mailserver, Timeout => 60);

$messnum = $pop3->login($user,$pass);
$pop3->quit();

print "Content-type: text/html\n\n";
print "You have $messnum in your mailbox.";

die;

code-----------------------------------------

Any thoughts would be appriciated. If I rem out the login and quit statements the code runs fine, but obviously no value for the number of messages variable...

Thanks,
Mike


Jasmine
Administrator / Moderator

Feb 13, 2000, 4:25 PM

Post #2 of 6 (834 views)
Re: Net::POP3 [In reply to] Can't Post

Try this:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


use Net::POP3;

$user = "(my user name)";
pass = "(my password)";
$mailserver = "pop3.(my domain).com";

$pop3 = Net::POP3->new($mailserver, Timeout => 60);

$pop3->login($user,$pass);
($newmess,$totalmess) = $pop3->ping($user)
$pop3->quit();

print "Content-type: text/html\n\n";
print "You have $newmess new in your mailbox, and $totalmess total messages";

exit;
</pre><HR></BLOCKQUOTE>

You'll want to make sure that pop3.whatever.com is really your pop3 server. Otherwise, it won't work. You may also wish to use the debug option in the constructor.

Docs for Net::POP3


MStates
Deleted

Feb 13, 2000, 10:47 PM

Post #3 of 6 (834 views)
Re: Net::POP3 [In reply to] Can't Post

OK, got the connection to the pop server working now, thanks for the help. Now another question...

When I go through the header information the

Reply-To:
To:

sections ar blank and the

From:

section displays the name the is in my mail configuration... I know that the reply to is set up in my email client that I sent the message from and don't know why that it is not reading it from the header. If I download the same message with my e-mail client I get the reply to info and in the from section there is also an e-mail address...

Any ideas of what is going on?



darian
Deleted

Feb 15, 2000, 5:01 AM

Post #4 of 6 (834 views)
Re: Net::POP3 [In reply to] Can't Post

Ok I tried the code you have above but can't seem to get it to connect. I get the error:

Can't call method "login" on an undefined value at D:\path\cgi-bin\netpop.cgi line 19.

My code reads as below:

$pop3 = Net::POP3->new('$pop_server', Timeout => 60);
$pop3->login($username, $password);
($newmess,$totalmess) = $pop3->ping($username);
@messages = $pop3->list;
$pop3->quit;

print "Content-type: text/html", "\n\n";
print "<h3>You have $newmess new messages.</h3>\n";
foreach $message (@messages) {
print "$message\n";
print "<hr>\n";
}

Now I know that my pop server address, username and password are correct as I have written another pop mail checker useing Mail::POP3Client. I want to use Net::POP3 as you can get the new messages with it and I can't seem to find a way to tell which messages are new using Mail::POP3Client. I would prefer to us my old program if anyone knows a way to tell which are new messages using Mail::POP3Client. Thanks.



japhy
Enthusiast

Feb 15, 2000, 5:17 AM

Post #5 of 6 (834 views)
Re: Net::POP3 [In reply to] Can't Post

You put $pop_server in single quotes (so it is the literal string $pop_server, instead of the value of the variable. You also didn't check to see if all went as planned:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


$pop3 = Net::POP3->new($pop_server, Timeout => 60) or die "can't connect to $pop_server: $@";
</pre><HR></BLOCKQUOTE>


MStates
Deleted

Feb 15, 2000, 7:56 AM

Post #6 of 6 (834 views)
Re: Net::POP3 [In reply to] Can't Post

Here is the sode that I am currently using to print the contents of the header...

code-----------------------------------------

use Net::POP3;

print "Content-type: text/html\n\n";

$user = "(my user)";
$pass = "my password)";
$mailserver = "(my server).com";

$pop3 = Net::POP3->new($mailserver, Timeout => 60);

$messnum = $pop3->login($user,$pass);
for ($i = 1; $i <= $messnum; $i++) {
$subject = $pop3->top($i);
foreach $test (@$subject) {
# if (index($test, "Subject:")>=0) {
print "Header of message $i: $test<br>";
# }
}
}

$pop3->quit();

die;

code-----------------------------------------

Can anyone tell me why the

Reply-To:
To:

fields come back blank and the

From:

comes back with just the Name that is set in my mail client that I sent the message from...

I know the the reply to is set up in my mail client that the message was sent from and if I retieve the same message using my mail client and view the header I have a reply to addy and the address that it was sent from after the name in the

From:

section of the header...

Any thoughts???

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives