Tutorial by Examples

To use the IMAP functions in PHP you'll need to install the IMAP extension: Debian/Ubuntu with PHP5 sudo apt-get install php5-imap sudo php5enmod imap Debian/Ubuntu with PHP7 sudo apt-get install php7.0-imap YUM based distro sudo yum install php-imap Mac OS X with php5.6 brew reinsta...
To do anything with an IMAP account you need to connect to it first. To do this you need to specify some required parameters: The server name or IP address of the mail server The port you wish to connect on IMAP is 143 or 993 (secure) POP is 110 or 995 (secure) SMTP is 25 or 465 (secure) N...
Once you've connected to your mailbox, you'll want to take a look inside. The first useful command is imap_list. The first parameter is the resource you acquired from imap_open, the second is your mailbox string and the third is a fuzzy search string (* is used to match any pattern). $folders = ima...
You can return a list of all the messages in a mailbox using imap_headers. <?php $headers = imap_headers($mailbox); The result is an array of strings with the following pattern: [FLAG] [MESSAGE-ID])[DD-MM-YYY] [FROM ADDRESS] [SUBJECT TRUNCATED TO 25 CHAR] ([SIZE] chars) Here's a sample o...

Page 1 of 1