php - Retrieve email address from imap header -
i'm using php imap function imap_header
extract full header , imap_fetch_overview
extract raw header. both functions gives me stdclass object , arrays respectively.
i clean , before further processing. or can contain thing this, test user <test@test.com>
also in see test user
, no email address until use firebug.
how test@test.com these objects, arrays?
this result imap_fetch_overview
array ( [0] => stdclass object ( [subject] => testing [from] => test user [to] => testuser2@test.com [date] => wed, 17 apr 2013 18:43:46 +0530 [message_id] => <abcdef1244.93784jgsfk@test.com> [size] => 3443 [uid] => 1234 [msgno] => 123 [recent] => 0 [flagged] => 0 [answered] => 0 [deleted] => 0 [seen] => 0 [draft] => 0 [udate] => 1366204439 ) )
there hidden <test@test.com>
next test user. how extract email address?
similarly 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] => <abcdef1244.93784jgsfk@test.com> [toaddress] => testuser@test.com [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 )
a preg_match
obvious answer cant seem figure out how perform on bit email address not seen in browser present when inspected firebug. appreciated.
thanks.
you can go 1 step further imap_rfc822_parse_adrlist()
docs:
$toaddresses = imap_rfc822_parse_adrlist('test user <test@test.com>', 'localhost'); print_r($toaddresses); array ( [0] => stdclass object ( [mailbox] => test [host] => test.com [personal] => test user ) )
Comments
Post a Comment