To get all unread and read email using gmail login details. This require IMAP library in php. you can install it easily by terminal command in linux.
apt-get install php5-imap
- Firstly put imap.php into codeignitor library folder.
- Load library into your controller like
$this->load->library('imap');
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = '[email protected]';
$password = '123456';
$subject = 'HR';
$maximum = '10';
- Now call Imap function into your controller like.
$response = $this->imap->get_emails($hostname,$username,$password,$subject,$maximum);
It will return all email data into response.