Accessing Mail via POP3 in Perl & PHP
POP3 stands for Post Office Protocol version 3, it's application layer Internet Protocol used by various desktop email clients, and web-based email services to fetch email from a remote server over a TCP/IP connection. Until sometime back POP3 was the de facto standard for email retriveal, but the recently popularity and additional features of IMAP has taken a big chunk of users from POP3. One of the notable reasons for popularity of IMAP over POP3 was when GMail starting providing free IMAP service, whereas Yahoo! Mail requires a paid subscription for POP3 access. Some popular POP3 email clients are Outlook Express, Microsoft Office Outlook, Mozilla Thunderbird, fetchmail, etc.
POP3 had earlier versions of the protocol, informally called POP1 and POP2, now obsolete. In casual words POP almost always means POP3 in the context of e-mail protocols. All of us must have a at some point of time accessed mail using POP3, either in office or somewhere else. In this article we'll see how to programatically access and retrive email using POP3, we can use it for many purpose, just for checking new mails, automated backups, etc.
For accessing emails using POP3 in perl we'll require the Perl module Net::POP3, you can get it from here. In the example below we'll connect to a POP3 server and retrive the mail headers and read who sent the mail, and also display total size of the mailbox.
For doing the same in PHP, we'll require the PEAR package Net_POP3, get it from here. With the PEAR package it's a bit easier to get the headers, it already has an in-built method getParsedHeaders() which returns the parsed headers of the specified message. Let's go ahead and try it out.
Hope this was helpful, enjoy coding!
|All times are GMT +5.5. The time now is 07:22.|