0
我的電子郵件正文包含電子郵件和電話號碼字段我想提取這些字段並存儲在數據庫中,我該如何做? 這是我的PHP代碼...如何使用PHP(imap函數)獲取電子郵件正文的特定部分?
<?php
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = "myusername";
$password = "mypassword";
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
$emails = imap_search($inbox,"ALL");
if($emails) {
$output = '';
foreach($emails as $email_number) {
$headerInfo = imap_headerinfo($inbox,$email_number);
$structure = imap_fetchstructure($inbox, $email_number);
$overview = imap_fetch_overview($inbox,$email_number,0);
$message = imap_qprint(imap_fetchbody($inbox,$email_number,1));
$output .= 'Body: '.$message.'<br />';
$structure = imap_fetchstructure($inbox, $email_number);
print_r($structure);
}
}
imap_close($inbox);
?>
餘米提供我的電子郵件正文的屏幕截圖,郵箱和手機號碼的這一切盈。我想提取它。
感謝名單@Muhammed Hafil。我得到一個空數組,但是如果我刪除了兩個連字符,那麼我將'Email:'作爲一個數組元素,你可以詳細說明這個模式嗎? –
你可以請發佈什麼是$消息 –
$ message =「商業查詢爲利斯特--------- 買家聯繫信息:aaaaa 手機/手機:+91 ------- - , 電子郵件:無
買家的需求詳細信息: 我們要採購李斯特黃金UV LED超薄POP面板燈 尺寸:15英寸 功率:15瓦 請給我的價格和其他細節 。必填數量: - 「 –