大家好,我正在尝试废弃我的Gmail帐户中的所有电子邮件,并且我已成功完成了我无法理解的事情,我想从电子邮件正文中获取某些部分,但我无法理解我能做到吗这是我到目前为止所做的事情。
<?php
/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'ddum33165@gmail.com';
$password = 'abcde1234567890';
/* try to connect */
// try{
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
// }catch(Exception e){
// error_log("an error was encountered");
// }
/* grab emails */
$emails = imap_search($inbox,'ALL');
// var_dump($emails);
// /*Cycle through each ... */
// var_dump($emails);
if($emails) {
// /* begin output var */
$output = '';
/* put the newest emails on top */
rsort($emails);
/* for every email... */
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>';
}
// var_dump($output);
// echo $output;
}else{
var_dump("There are no emails to be displayed ");
}
/* close the connection */
imap_close($inbox);
请告诉我怎么做。我将如何提取电子邮件正文中的电话号码电子邮件