Hey Every once after a lot of R&D from google, now we could configure the email content read successfully here is the example of how to retrieve the email content.
PHP script email reader.php
here is the complete PHP script
<?php
set_time_limit(3000);
/* connect to gmail with your credentials */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'Bikash@bikash.com';
$password = 'XXXXX#';
/* try to connect */
$inbox = imap_open($hostname,$username,$password);
/* get all new emails. If set to 'ALL' instead
* of 'NEW' retrieves all the emails, but can be
* resource intensive, so the following variable,
* $max_emails, puts the limit on the number of emails downloaded.
*/
//$emails = imap_search($inbox,'ALL');
$date = date ( "d M Y", strToTime ( "-1 days" ) );
$emails = imap_search($inbox,'FROM "no-reply@tableau.com" SINCE "'.$date.'"');
/* useful only if the above search is set to 'ALL' */
$max_emails = 5;
/* if any emails found, iterate through each email */
if($emails) {
$count = 1;
/* put the newest emails on top */
rsort($emails);
/* for every email... */
$ArrayMessage = array();
foreach($emails as $email_number) {
//get information specific to this email
$overviewData = imap_fetch_overview($inbox,$email_number,0);
//echo '<pre>'; print_r($overviewData);
if(count($overviewData>0)){
$object = new stdClass();
$object->msgno = trim($overviewData[0]->msgno);
$object->uid = trim($overviewData[0]->uid);
$object->from = trim($overviewData[0]->from);
$object->to = trim($overviewData[0]->to);
$object->subject = $overviewData[0]->subject;
$object->message_id = $overviewData[0]->message_id;
$object->size = $overviewData[0]->size;
$object->recent = $overviewData[0]->recent;
$object->flagged = $overviewData[0]->flagged;
$object->answered = $overviewData[0]->answered;
$object->deleted = $overviewData[0]->deleted;
$object->seen = $overviewData[0]->seen;
$object->draft = $overviewData[0]->draft;
$object->udate = $overviewData[0]->udate;
//do store your database as per required
}}}
//Hope it will help you!
?>