PHP IMAP parser (IMAP class)

PHP IMAP parser (IMAP class)

Released 3 years ago , Last update 3 years ago

A PHP class for handling email operations via IMAP. Parse IMAP mailboxes and messages, as well as read and write emails.

With this PHP class you'll be able to connect to your IMAP server and start parsing email in minutes. You can check messages in mailboxes, read messages, and write emails.

Benefits

  • Time-Saving

    Your save ~80-200 developer hours. To learn top features of IMAP protocol and email RFC your need near 120 hours. With this IMAP class your can start your project in 1-2 minutes.

  • SIMPLE API INTERFACE

    Our IMAP class API is very simple and more useful that stardart imap_ php functions.
    Code works at PHP 5.2+, at any hosting with installed php_imap module.

  • Supports all most popular email formats

    IMAP parser supports tree-structured emails, html emails, text email, in any encoding, with any attachments.

Features

  • Quick read mailboxes

  • FLAG and unflag messages

    Seen, answered, deleted, flagged, your labels.
  • Deleting messages

  • Batch operations

    Batch changes of messages
  • Structured messages

    Retrieve structured message in array.
  • read message headers

    From, to, cc, subject, formatted subject,date, mailbox, uid, msgno, messageID, spam flag, auto-submitted flag, mailer-daemon flag and others.

 

Code Example

require(dirname(__FILE__).'/IMAP/include.php');

try {
    // connect to IMAP server
    $imap = new IMAP('mail.domain.com', 'username@domain.com', 'password');
    $imap->connect();

    // get list of all mailboxes
    $mailboxArray = $imap->getMailboxArray();
    print_r($mailboxArray);

    // prints:
    //    inbox
    //    sent
    //    trash
    //    junk
    //    ...

    // get all messages in INBOX (print array of UID)
    $uidArray = $imap->getMessageArray('inbox');
    print_r($uidArray);

    // prints:
    //    1750
    //    1751
    //    1752
    //    1753
    //    1754
    //    1755
    //    ...

    // get message headers by UID=1751. Prints formatted message array.
    $headerArray = $imap->getMessage('inbox', 1751, true);
    print_r($headerArray);

    // prints:
    //    [uid] => 1751
    //    [autosubmitted] => 0
    //    [msgno] => 5371
    //    [flagged] => 0
    //    [answered] => 0
    //    [seen] => 1
    //    [draft] => 0
    //    [deleted] => 0
    //    [recent] => 0
    //    [mailerdaemon] => 0
    //    [spam] => 0
    //    [from] => from@domain.com
    //    [to] => Array
    //        (
    //            [0] => to@domain.com
    //        )
    //    [date] => 2014-12-15 18:01:08
    //    [mailbox] => inbox
    //    [subject] => Re: subject name
    //    [messageid] => <3d380283bf74225f2b1ea39756b651ff@domain.com>
    //    [subjectgroup] => subject name

    // get full message by UID=1751. Prints formatted message array.
    $headerArray = $imap->getMessage('inbox', 1751);
    print_r($headerArray);

    // prints:
    //    [uid] => 1751
    //    [autosubmitted] => 0
    //    [msgno] => 5371
    //    [flagged] => 0
    //    [answered] => 0
    //    [seen] => 1
    //    [draft] => 0
    //    [deleted] => 0
    //    [recent] => 0
    //    [mailerdaemon] => 0
    //    [spam] => 0
    //    [from] => from@domain.com
    //    [to] => Array
    //        (
    //            [0] => to@domain.com
    //        )
    //    [date] => 2014-12-15 18:01:08
    //    [mailbox] => inbox
    //    [subject] => Re: subject name
    //    [messageid] => <3d380283bf74225f2b1ea39756b651ff@domain.com>
    //    [subjectgroup] => subject name
    //    [text] = ... text content of message
    //    [html] = ... html content of message
    //    [file] => Array
    //        (
    //            [0] => Array
    //                (
    //                    [name] => file.png
    //                    [type] => image/png
    //                    [content] => ... (binary content of attachments)
    //                )
    //        )

    // set message as seen
    $imap->setMessageSeen('inbox', 175, true);

    // set message as unseen
    $imap->setMessageSeen('inbox', 175, false);

    // set message as flagged
    $imap->setMessageFlagged('inbox', 175, true);

    // set message as unflagged
    $imap->setMessageFlagged('inbox', 175, false);

    // set message as answered
    $imap->setMessageAnswered('inbox', 175, true);

    // set message as unanswered
    $imap->setMessageAnswered('inbox', 175, false);

    // mark group of messages as seen
    $imap->setMessageSeen('inbox', 171, true, true);
    $imap->setMessageSeen('inbox', 172, true, true);
    $imap->setMessageSeen('inbox', 173, true, true);
    // and saves it
    $imap->expunge();

    // delete message
    $imap->deleteMessage('inbox', 174);

    // mark group of messages as deleted
    $imap->deleteMessage('inbox', 175, true);
    $imap->deleteMessage('inbox', 176, true);
    $imap->deleteMessage('inbox', 177, true);
    // and delete it
    $imap->expunge();

    // disconnect from server
    $imap->disconnect();
} catch (Exception $imapEx) {
    print_r($imapEx);
}

Pricing

14 day 14-day money-back guarantee

$9.99

Hosted License

  • Perpetual license

  • 1 site, unlimited servers

  • No distribution (hosted use only)

  • Commercial use

  • 1 month support

Need custom services for this product? Get a quote
2 licenses, starting from From » $9.99 View Licenses

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.

or Get a quote

for customization or integration services


Or enter your name and Email
  • C clicetcom License holderHosted License
    1 month support
    Purchased on Nov 13, 2017
    1 month ago
    Doesn't work... give me money back please.
  • TS Tristan Smith 3 months ago
    How can I order this since your payment system doesn't work. "Invalid Request: None of the fields are specified to identify the receiver"