Question

Locked

Using pop3 from php

By dharmendra.tolani ·
Hi,
I am trying to access mails on my gmail account
through pop3 in php.
but it doesn't seem to work.

Below is my code and the output I get after
executing it:
So only question is how to make it work.
code ->
<html>
<body>
<?php
$mbox = imap_open("{pop.gmail.com:995/pop3/ssl}", "userid@gmail.com", "password");

echo "reached here\n";

echo "Mailboxes\\n";

$folders = imap_listmailbox($mbox, "{pop.gmail.com:995}", "*");

if ($folders == false) {
echo "Call failed<br />\n";
} else {
foreach ($folders as $val) {
echo $val . "<br />\n";
}
}

echo "<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($mbox);

if ($headers == false) {
echo "Call failed<br />\n";
} else {
foreach ($headers as $val) {
echo $val . "<br />\n";
}
}

imap_close($mbox);
?>
</body>
</html>

output ->

Warning:
imap_open() [function.imap-open]: Couldn't open stream {pop.gmail.com:995/pop3/ssl} in pop3.php on line 4
reached here
Mailboxes

Warning: imap_listmailbox(): supplied argument is not a valid imap resource in pop3.php on line 7
Call failed
Headers in INBOX

Warning: imap_headers(): supplied argument is not a valid imap resource in pop3.php on line 18
Call failed

Warning: imap_close(): supplied argument is not a valid imap resource in pop3.php on line 28

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

re: using pop3 in php

by ThumbsUp2 In reply to Using pop3 from php

Take each error one at a time. Since the OPEN failed, the rest of the errors are generated because of it. So, concentrate on the error "Could not open stream" indicating the imap_open statement is not working.

Have you checked with g-mail for the correct input string needed to connect to their pop3 server? Are you sure the server is located at pop.gmail.com? Are you sure it's SSL? Is port 993 the correct port? Usually, the pop3 port is 110? Is the format "username@gmail.com" the proper username, or does it just need to be "username"?

Collapse -

Great article

by Galeazzo In reply to Using pop3 from php

I have read your blog it is very helpful for me. I want to say thanks to you. I have bookmark your site for future updates ,
<a href="http://www.3cpromotion.com">gadget aziendali</a>
A very good and informative article indeed . It helps me a lot to enhance my knowledge, I really like the way the writer presented his views.
<a href="http://www.fuoristradausati.net">fuoristrada usati</a> , thanks very much
<a href="http://www.kijijincontri.com/incontri-roma.html">incontri roma</a> . regards

Back to Software Forum
3 total posts (Page 1 of 1)  

Software Forums