PHP Classes

How to Read Your Inbox Retrieving Email Messages using PHP from Gmail, Hotmail and Yahoo via POP3 - POP3 e-mail client package blog

Recommend this page to a friend!
  All package blogs All package blogs   POP3 e-mail client POP3 e-mail client   Blog POP3 e-mail client package blog   RSS 1.0 feed RSS 2.0 feed   Blog How to Read Your Inbo...  
  Post a comment Post a comment   See comments See comments (21)   Trackbacks (0)  

Author:

Viewers: 1,830

Last month viewers: 591

Package: POP3 e-mail client

Nowadays, most Web mail sites provide POP3 support, so you can retrieve your mailbox messages using PHP or any other language.

However, each system uses different ports and encryption configuration that you need to know in order to access them.

This article provides information on the details of accessing the messages on some of the most popular Web mail systems via POP 3.

It also provides a solution to a common problem, which is how to retrieve only the newly received messages when you never delete messages from the mailbox.




Loaded Article

Contents

Gmail and Google App Accounts

Hotmail and Windows Live accounts

Yahoo! Mail

Other Web mail systems

Retrieving only the new unread messages

Processing retrieved e-mail messages

Gmail and Google App Accounts

Before retrieving messages from Gmail accounts, you need to enable POP support for your account. You can do that by going to the settings page, click on the tab named Forwarding and POP/IMAP, and enable one of the POP options that exposes the messages in your mailbox either since ever or only from now on.

Options to enable POP3 support in Gmail mailboxes

Gmail POP3 server responds in the port 995 and it requires that you enable SSL/TLS encryption. The user name must be the account e-mail address including the domain part.


$pop3 = new pop3_class; $pop3->hostname = "pop.gmail.com"; $pop3->port = 995; $pop3->tls = 1; $user = "account@gmail.com"; $password = "account password";

Hotmail and Windows Live accounts

Accessing Hotmail accounts is similar to Gmail, except that it does not need to explicitly enable POP support in the Web interface.


$pop3 = new pop3_class; $pop3->hostname = "pop3.live.com"; $pop3->port = 995; $pop3->tls = 1; $user = "account@hotmail.com"; $password = "account password";

Yahoo! Mail

Currently, accessing Yahoo! Mail mailbox messages via POP3 is restricted to paying users of the Yahoo! Mail plus service. Other than that, most parameters are similar to Gmail and Hotmail, except that the user name should be just the account user name, thus without the @ character and the domain name.


$pop3 = new pop3_class; $pop3->hostname = "pop.mail.yahoo.com"; $pop3->port = 995; $pop3->tls = 1; $user = "account"; $password = "account password";

Other Web mail systems

This article only covers a few of the most popular Web mail systems. If you know how to configure the POP3 access to other popular mail systems, please post a comment to this article, so you can share that information for benefit of other readers.

Retrieving only the new unread messages

Some applications retrieve e-mail messages from a mailbox via POP3 but do not delete the messages. Therefore they cannot easily determine if the message was already retrieved or is new.

Unfortunately, the POP3 protocol does not provide a way to determine which messages in a mailbox are new or were already retrieved in a previous access.

One way to solve this problem is to keep track of the message identifiers of the messages read so far, for instance storing those identifiers in a database.

The POP3 class ListMessage function can list all the messages if you pass an empty string as first parameter. If you pass the value 1 as second parameter, it will return an array with the unique identifier of all messages.

If you lookup your database of previously retrieved messages and compare with the unique identifiers of the messages in the POP3 mailbox, you can easily determine which messages are new by finding the unique identifiers of messages not present in your database.

This is not a very efficient solution if you have many messages in your mailbox, so it may take a while, but at least it is a solution that works when you retrieve messages via POP3.

Processing retrieved e-mail messages

Once you retrieve the new messages, you need to process them eventually parsing the messages to extract their information. That is a task that can be easily achieved using a separate PHP MIME message parser class in conjunction with the POP3 class.

That is a subject that was already covered in a past post of this blog about processing incoming mail messages using PHP.

If you have doubts or questions about how to achieve other purposes with this class that you would like to be covered in eventual posts of this blog, feel free to post a comment to this article.




You need to be a registered user or login to post a comment

Login Immediately with your account on:



Comments:

15. Microsoft Outlook Not Implemented - outlooksupport (2018-09-13 05:09)
sunilggjj1@gmail.com... - 0 replies
Read the whole comment and replies

14. pros of POP - Hazel snow (2018-09-06 10:24)
why use POP... - 0 replies
Read the whole comment and replies

13. Mail Support - David (2018-03-12 19:59)
Email Support... - 0 replies
Read the whole comment and replies

12. Attachments download - emmanuell (2017-03-29 19:04)
Attachments download... - 1 reply
Read the whole comment and replies

10. integarte gmail and yahoo email into my web application - vishnu (2016-06-20 11:06)
email from gmail and yahoo... - 1 reply
Read the whole comment and replies

9. 0 message in gmail box - afpa (2015-10-27 00:01)
error with pop.gmail.com... - 1 reply
Read the whole comment and replies

6. Not Fetching Mail from Inbox - mohamad mantach (2013-12-19 21:03)
Not Fetching Mail from Inbox... - 1 reply
Read the whole comment and replies

5. ' - Devendra Kumar Rathore (2013-09-09 08:23)
'... - 0 replies
Read the whole comment and replies

4. what should be the base - bhutto (2012-12-12 12:17)
browse_mail.php or parse_message?... - 1 reply
Read the whole comment and replies

3. fashinefa - fashinefa (2011-10-14 09:50)
Ture Religion jeans for womens... - 0 replies
Read the whole comment and replies



  Post a comment Post a comment   See comments See comments (21)   Trackbacks (0)  
  All package blogs All package blogs   POP3 e-mail client POP3 e-mail client   Blog POP3 e-mail client package blog   RSS 1.0 feed RSS 2.0 feed   Blog How to Read Your Inbo...