Web Hosting Talk







View Full Version : Read POP3 Emails in PHP?


adaml
08-16-2005, 06:04 PM
How would i read emails in php using the "fopen"? I cant use imap() as my server wont support it. I know that i would need to create a connection to the mail server and then login.

But what do i need to do to check the Messages that are in the server, as in show the headings and then be able to see the actual body of the message?


Thanks in Advanced for the help!

Slidey
08-17-2005, 10:40 AM
pop is a pretty simple protocol

try this:

telnet mailserver 110
user user@domain.com
pass secret
list
stat
retr 1
dele 1 (this will delete the first mail)
rset (this will 'undelete' any deleted mails from this session only)
quit


take a look at http://www.ietf.org/rfc/rfc1939.txt

znarf
08-17-2005, 03:19 PM
don't use fopen(), use fsockopen(). I've written a simple PHP class for this purpose. Let me know me if you want me to send it to you. There are certainly similarly classes somewhere out there.

adaml
08-18-2005, 01:08 PM
Hey znarf could you send me the class ? Saves me writing my own!

Slidey - I know how to use Pop in telnet, i was using fopen + the pop commands to communicate. Thanks anyway :D

tiamak
08-18-2005, 09:52 PM
you may use http://pear.php.net/package/Net_POP3
examples are included there also :)