问题
I am working on email application.I write code that can fetch emails from server ( currentyl i am testing on gmail server).when i retrive specific emails ,i try to get email text body ,but with the replied message orignal message is also appended .So i want to get the new message with out the replied message that are appended.Any help will be appricaited.My code is below :
/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'mahmoodkk@gmail.com';
$password = 'mahmood';
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
$emails = imap_search($inbox,'ALL');
/* if emails are returned, cycle through each... */
if($emails) {
$output = '';
rsort($emails);
foreach($emails as $email_number) {
/* 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="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>';
echo $message; // here i want to seperate the appended and new message.
}
}
imap_close($inbox); .
I got this output :

回答1:
@Mahmood Rehman you implement this Article : http://davidwalsh.name/gmail-php-imap ???
I hope next lines to help you.
Do you think is good idea to use : PHP DOM (http://php.net/manual/en/book.dom.php)
And more specific DOMDocument::loadHTML AND DOMElement::getElementsByTagName.
来源:https://stackoverflow.com/questions/18584244/fetch-new-message-without-reply-from-email-in-php