PHP Classes

Viv OAuth IMAP: Access messages in IMAP server using OAuth token

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 694 All time: 4,716 This week: 40Up
Version License PHP version Categories
viv-oauth-imap 1.0.11MIT/X Consortium ...5Email
Description 

Author

This class can access email messages in an IMAP server using an OAuth token.

It can connect to a IMAP server authenticating with either a user name and password or using a previously obtained OAuth token.

The class can also perform other operations with the IMAP server mailbox like listing folders, selecting folders to access, getting the total of emails in a folder, getting the headers and bodies of email messages, logout and disconnect.

Innovation Award
PHP Programming Innovation award nominee
November 2013
Number 3


Prize: One copy of the Zend Studio
IMAP is a popular protocol for accessing servers that receive email messages for users.

OAuth is a protocol that is used to obtain permission from an user to access server resources on his behalf.

This class can access to a IMAP server that supports user authentication using OAuth tokens.

Manuel Lemos
Picture of Vivek Muthal
  Performance   Level  
Innovation award
Innovation award
Nominee: 1x

 

Details

# VivOAuthIMAP ####Version: 1.0 ##Overview VivOAuthIMAP is a library to support OAuth for IMAP. PHP's default library imap_open doesn't have support for OAuth. So a quiick solution will be this library. ###Features * Connect to IMAP using OAuth * Count Total Mails * Fetch Mails Headers * Fetch Mails Body * List folders of mailbox * Switch to folders easily * Append Message ###Usage $imap = new VivOAuthIMAP(); $imap->host = 'ssl://imap.gmail.com'; $imap->port = 993; //Using Username And Password $imap->username = 'changeMe@gmail.com'; $imap->password = 'changeMe'; //Or you can use access token //$imap->accessToken = 'tokenreceivedbyoauthlibrary' if ($imap->login()) { /* $header = $imap->getHeader(1); //Returns mail header array $mails = $imap->getMessage(1); //Returns mails array $headers = $imap->getHeaders(1,10); //Returns mail headers array $mails = $imap->getMessage(2); //Returns mails array $total = $imap->totalMails(); //By default inbox is selected $total = $imap->totalMails('Folder Name'); //Any folder which exist can be passed as folder name $folders = $imap->listFolders(); //Lists all folders of mailbox $imap->selectFolder('Folder Name'); // Default is INBOX autoselected after login */ $mails = $imap->getMessages(1, 20); foreach ($mails as $mail) { //Using mime_parser you can parse the rfc822 format mail or can write own parser //Here in example used a mime_parser_class $mime = new mime_parser_class(); $parameters = array('Data' => $mail); $mime->Decode($parameters, $decoded); /* //See how much variables you can access echo "<pre>"; print_r($decoded); echo "</pre>"; */ echo "<b>From :</b> " . $decoded[0]['ExtractedAddresses']['from:'][0]['address'] . " "; echo "<b>Subject :</b> " . $decoded[0]['Headers']['subject:'] . "<br>"; echo "======================================================== <br>"; } } ##Requirement * PHP Version > PHP 5.3+ * PHP Extensions needs to enable * php_openssl * php_curl * php_sockets ##License ---- The MIT License (MIT) Copyright (c) 2013 Vivek Muthal Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Author : Vivek Muthal Email : vmuthal.18@gmail.com Website : [www.vivsoftware.in](http://www.vivsoftware.in)

  Files folder image Files (87)  
File Role Description
Files folder imageexample (1 file, 2 directories)
Files folder imagenbproject (2 files, 1 directory)
Files folder imagesrc (1 file)
Accessible without login Plain text file License.txt Doc. Documentation
Accessible without login Plain text file README.md Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:694
This week:0
All time:4,716
This week:40Up