Fetching mail from a POP3 server using php

Somewhat surprisingly, PHP’s imap library can be also used for working with POP3 mailboxes. Most of the advanced IMAP features won’t work, of course (e.g. folders or fetching message parts), but the basic POP3 functionality is implemented.

The main difference is the option string that you’re passing to imap_open – to quote that page:

// To connect to a POP3 server on port 110 on the local server, use:
$mbox = imap_open ("{localhost:110/pop3}INBOX", "user_id", "password");

Other than that, it’s fair sailing – you won’t need more than imap_open, imap_num_msg, imap_body, imap_delete and imap_close for basic POP3 access.

Leave a Comment