Accessing your google mail using php IMAP feature. The php IMAP functions does a lot of interesting work. the following code is written for gmail. This code connects to the gmail imap service through SSL which is listening on port 993. others servers listen to port 143 by default.
The return value is used with other functions to get the desired result.
here it is imap_listmailbox and imap_headers function.
imap_listmailbox will list all the mail boxes with respect to the mail server like inbox, sent, deleted etc..
imap_headers will list all the head of ever message that is the subject of each message in an default order. you can use the iteration index to open a specific message body to read the content of a mail.
so, for now … here we go…
<?php $conx = imap_open("{imap.gmail.com:993/imap/ssl}", "yourid@gmail.com", "yourpassword"); echo "<h1>Mailboxes</h1>\n"; $folders = imap_listmailbox($conx, "{imap.gmail.com:993}", "*"); if ($folders == false) { echo "Call failed<br />\n"; } else { foreach ($folders as $val) { echo $val."<br />"; } } echo "<h1>Headers in INBOX</h1>\n"; $headers = imap_headers($conx); if ($headers == false) { echo "Call failed<br />\n"; } else { foreach ($headers as $val) { echo $val . "<br />\n"; } } imap_close($conx); ?> |
…
Recent Comments