Imap for CakePHP 2.6?

Hi,
I found solution for Imap server “Cakephp-tools” :

Could somebody to show how to use it?

I’ve created:
In database.php :

public $imapSrc = array(
        'datasource' => 'ImapSource',
        'host' => 'localhost',
        'login' => 'root',
        'password' => '',
//        'database' => 'cook',
//        'encoding' => 'utf8',
            'username' => 'meuser@gmail.com',
            'password' => 'pass',
            'email' => 'meuser@gmail.com',
            'server' => 'imap.gmail.com',
            'type' => 'imap',
            'ssl' => true,
            'mailbox' => 'INBOX',
            'retry' => 3,
            'error_handler' => 'php',
//            'auto_mark_as' => ['seen'],
            'auto_transform' => true, // transform attachments back into the original file content
        'imap' => ['port' => 993],
        'pop3' => ['port' => 465],
    );
}

In Imapme.php:

<?php
App::uses('AppModel', 'Model');
/**
 * Category Model
 *
 * @property Package $Package
 */
class Imapme extends AppModel {

    public $name = 'Imapme';
    public $useDbConfig = 'imapSrc';
    public $useTable = false;
    public $displayField = "subject";


    //Model::exists()  must return true
    function exists($reset = false) {
        return true;
    }


}

In ImapmeController.php :

<?php
App::uses('AppController', 'Controller');
/**
 * Packages Controller
 *
 * @property Package $Package
 * @property PaginatorComponent $Paginator
 * @property SessionComponent $Session
 */
class ImapmesController extends AppController {

    /**
     * Components
     *
     * @var array
     */
    public $components = array('Paginator', 'Session', 'Data.CountryProvinceHelper');
    public $helpers = array('Tools.Format', 'Data.Data', 'Js');


    public function index()
    {
        $emails = $this->Imapme ->find('all', array(
            'order' => array('message_date' => 'DESC')
        ));

      debug($emails);

    }


}

I got :
Fatal error: Call to a member function find() on null in

Help me who knows how it works , please.

Thank you.

There’s nothing here that would seem to initialize $this->CompanyEmail. That particular error has nothing whatsoever to do with IMAP.

Thank you.
It was miss typing.
I can connect to Google now.
But for me unclear ->find( $conditions ).
What I can write as $conditions. For example, if I use

$emails = $this->Imapme->find('all', array(
            'order' => array('message_date' => 'DESC')
        ));

I get :

[ **Notice**  (8)](javascript:void(0);): Undefined property: stdClass::$messageId [ **APP\Model\Datasource\ImapSource.php** , line  **971** ]

Does it work if you don’t provide any conditions or order? Just ->find('all');?

It’s uselees , it works more than 10 min.
If I use $this->Imapme->find(‘first’); I see one message like :

array(
	'Imapme' => array(
		'id' => (int) 577,
		'message_id' => null,
		'email_number' => ' 536',
		'from' => 'no-reply@accounts.google.com',
		'from_name' => 'Google',
		'reply_to' => 'no-reply@accounts.google.com',
		'reply_to_name' => 'Google',
		'sender' => 'no-reply@accounts.google.com',
		'sender_name' => 'Google',
		'subject' => 'Critical security alert',
		'slug' => 'Critical-security-alert',
		'header' => 'Delivered-To: myEmail@gmail.com
Received: by 2002:a17:90a:d982:0:0:0:0 with SMTP id d2csp6531357pjv; Wed, 31
 Jul 2019 10:20:50 -0700 (PDT)
X-Received: by 2002:a9d:19cc:: with SMTP id
 k70mr88861165otk.304.1564593650878; Wed, 31 Jul 2019 10:20:50 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1564593650; cv=none; d=google.com;
 s=arc-20160816;
 b=XSx4R+6M0pj4Lfk2L3WrMNM1mAxNdGJ/h0lKNCR7Afpggf1IslYhVxMDVIH4On2O8P
 cSB+BnfzK6VaaXsYZ2o4KoQDh+yiKE2KiP7I9BnaAnm31xEYfgWfFSAYJfzPgznpkiKX

Is there more, apart from the actual message body, that follows this? If not, I don’t see any message_date field that you might be able to sort on, as you tried to do in the earlier code example.

No firm idea on what you might be doing wrong here, as I know nothing at all about the plugin in question. Hopefully, someone that has experience with it will come along. Or contact the plugin author directly?