Retrieving the gmail messages with php is much easier then you thing . here is the Imap extension by which we can fetch the gmail messages . you just need to gmail username and password and use this code to fetch the gmail messages.

/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'gmail username';
$password = 'gmail pwd';

/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());

/* grab emails */
$emails = imap_search($inbox,'ALL');

/* if emails are returned, cycle through each... */
if($emails) {
	
	/* begin output var */
	$output = '';
	
	/* put the newest emails on top */
	rsort($emails);
	
	/* for every email... */
	$output.='<div class="cointainer">';
	foreach($emails as $email_number) {
         // you can also use for loop to fetch limited emails
	//for($i=0;$i<=100;$i++)
	//{	
		$email_number=$emails[$i];
		/* get information specific to this email */
		$overview = imap_fetch_overview($inbox,$email_number,0);
		$message = imap_fetchbody($inbox,$email_number,2);
		
		/* output the email header information */
		$output.="<div class='single-email'>";
		$output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
		$output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
		$output.= '<span class="from">'.$overview[0]->from.'</span>';
		$output.= '<span class="date">on '.$overview[0]->date.'</span>';
		$output.= '</div>';
		/* output the email body */
		$output.= '<div class="body">'.$message.'</div>';
		$output.= '</div>';
	}
	$output.= '</div>';
	echo $output;
} 

/* close the connection */
imap_close($inbox);

Now add some style if you want to display the messages .

.single-email{
	background: #e2e2e2;
    padding: 5px;
    margin-bottom: 3px;
}
.subject {
    font-weight: bold;
    display: block;
}
span.from {
    font-size: 12px;
}
span.date {
    font-size: 12px;
    font-style: italic;
    float: right;
}
.cointainer {
    width: 53%;
    margin: 0 auto;
}

with this code you can fetch inbox of any host provider you just need the host name port and the credentials(username and password ) like

$hostname = '{imap.yahoo.com:993/imap/ssl}INBOX'; //to fetch yahoo messages
$hostname = '{imap.xyz.com:993/imap/ssl}INBOX'; // to xyz host messages

You can also apply a filter on the inbox message i.g if you want to fetch only unseen messages or seen messages or all .like given below

$emails = imap_search($inbox,'ALL');  to fetch all messages 
$emails = imap_search($inbox,'SEEN');  to fetch seen messages only 
$emails = imap_search($inbox,'UNSEEN');  to fetch unseen messages only 
http://codingbin.com/wp-content/uploads/2015/12/Untitled-1-copy1.jpghttp://codingbin.com/wp-content/uploads/2015/12/Untitled-1-copy1-150x150.jpgdevidphpRetrieving the gmail messages with php is much easier then you thing . here is the Imap extension by which we can fetch the gmail messages . you just need to gmail username and password and use this code to fetch the gmail messages. Now add some style if you...coding, php, wordpress, yii, cakephp, and  jquery

Are you want to get implementation help, or modify or extend the functionality of this script? Submit paid service request