PHP Classes

PHP IMAP Search: Find and save messages in IMAP server to database

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 57%Total: 230 All time: 8,156 This week: 49Up
Version License PHP version Categories
base_imap 1.0GNU General Publi...5Email, PHP 5, Databases, Searching
Description 

Author

This class can find and save messages in IMAP server to database.

It can connect to a given IMAP server and access a given mailbox account.

The class can search for messages in the mailbox based on given criteria like ALL, ANSWERED, BCC, BEFORE, BODY, CC, DELETED, FLAGGED, FROM, KEYWORD, NEW, OLD, ON "date", RECENT, SEEN, SINCE, SUBJECT, TEXT "string", TO, UNANSWERED, UNDELETED, UNFLAGGED, UNKEYWORD "string" and UNSEEN.

The found messages can be saved to a MySQL database table using MySQLi.

Picture of Abhijit Jagtap
  Performance   Level  
Name: Abhijit Jagtap <contact>
Classes: 1 package by
Country: India India
Age: 31
All time rank: 4061276 in India India
Week rank: 170 Up21 in India India Up

Example

<?php
ini_set
('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ERROR);
require_once
'src/imap.php';
/*
 * imap credentials goes here
 */
$authhost = "{xxxx.net:143/novalidate-cert}INBOX";
$email = "yyy@xxxx.net"; //dummy text. I swear i dont have typo here
$emailPassword = "zzzz"; //dummy text. No typo here.


$imap = new imap($authhost, $email, $emailPassword);
/*
 * if you want to save in db.
 */
$imap->save_into_db = FALSE; //default its TRUE
/*
 * if @save_into_db=TRUE then plz provide following details
 */
$imap->serverIP = "localhost";
$imap->userName = "****";
$imap->userPassword = "********";
$imap->databaseName = "db_name";

/*
 * get new mails
 */
$imap->search("UNSEEN");

/*
 * ooooh its done!
 */


  Files folder image Files (3)  
File Role Description
Files folder imagesrc (1 file)
Accessible without login Plain text file example.php Example To find the unread emails when looping through look for the ->Unseen property like so:
Accessible without login Plain text file mails.sql Data sql file

  Files folder image Files (3)  /  src  
File Role Description
  Plain text file imap.php Class class file

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  
 0%
Total:230
This week:0
All time:8,156
This week:49Up
 User Ratings  
 
 All time
Utility:83%StarStarStarStarStar
Consistency:83%StarStarStarStarStar
Documentation:-
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:57%StarStarStar
Rank:1674