我使用php imap函數imap_header
來提取完整標題,並使用imap_fetch_overview
來提取原始標題。這兩個函數分別爲我提供了stdClass對象和數組。從imap標題檢索電子郵件地址
我希望在進一步處理之前始終保持清潔。有時,一個從或向可以包含一些像這樣的事情, Test user <[email protected]>
而且目前我從我只看到Test User
並沒有電子郵件地址,直到我用螢火蟲。
如何從這些對象數組中獲取[email protected]?
這是結果我從imap_fetch_overview
Array
(
[0] => stdClass Object
(
[subject] => Testing
[from] => Test User
[to] => [email protected]
[date] => Wed, 17 Apr 2013 18:43:46 +0530
[message_id] => <[email protected]>
[size] => 3443
[uid] => 1234
[msgno] => 123
[recent] => 0
[flagged] => 0
[answered] => 0
[deleted] => 0
[seen] => 0
[draft] => 0
[udate] => 1366204439
)
)
那裏是一個隱藏<[email protected]>
旁邊的測試用戶。我如何提取該電子郵件地址?
同樣這是我從imap_header
stdClass Object
(
[date] => Wed, 17 Apr 2013 18:43:46 +0530
[Date] => Wed, 17 Apr 2013 18:43:46 +0530
[subject] => Test
[Subject] => Test
[message_id] => <[email protected]>
[toaddress] => [email protected]
[to] => Array
(
[0] => stdClass Object
(
[mailbox] => testuser
[host] => test.com
)
)
[fromaddress] => Test User
[from] => Array
(
[0] => stdClass Object
(
[personal] => Test User
[mailbox] => test
[host] => test.com
)
)
[reply_toaddress] => Test User
[reply_to] => Array
(
[0] => stdClass Object
(
[personal] => Test User
[mailbox] => test
[host] => test.com
)
)
[senderaddress] => Test User
[sender] => Array
(
[0] => stdClass Object
(
[personal] => Test User
[mailbox] => test
[host] => test.com
)
)
[Recent] =>
[Unseen] => U
[Flagged] =>
[Answered] =>
[Deleted] =>
[Draft] =>
[Msgno] => 123
[MailDate] => 17-Apr-2013 13:13:59 +0000
[Size] => 3443
[udate] => 1366204439
)
一個preg_match
得到將是顯而易見的答案,但只是不能似乎想出如何從那裏的電子郵件地址未在瀏覽器中看到的位執行,但在用螢火蟲檢查時存在。任何幫助表示讚賞。
謝謝。
在第一種情況下'$ arr [0] - > to'給我測試用戶。不給我電子郵件地址。但通過螢火蟲檢查後,我可以看到它將我的電子郵件地址視爲標籤。 '<[email protected]> [email protected]>'。任何想法爲什麼這樣做,應該做些什麼來糾正它? – ivn03