Getting X-Mailer attribute in php imap -
how can x-mailer attribute in php imap lib ?
i can't find fetch function attribute http://php.net/manual/en/function.imap-fetchheader.php
$inbox = imap_open($hostname,$username,$password) or die('cannot connect gmail: ' . imap_last_error()); $header = imap_fetchheader($inbox, 1); var_dump($header); /* close connection */ imap_close($inbox); output getting
string(405) "mime-version: 1.0 received: 10.42.228.195; wed, 16 feb 2011 21:18:06 -0800 (pst) date: wed, 16 feb 2011 21:18:06 -0800 message-id: <aanlktikj8ngggkg=of=v6vvnst2qz3wlnkuvzxpcs4tk@mail.gmail.com> subject: gmail on mobile phone from: gmail team <mail-noreply@google.com> to: test case2 <email@gmail.com> content-type: multipart/alternative; boundary=20cf302234f1c34163049c73853c "
method:
- fetch headers imap_fetchheader()
- extract x-mailer field headers
- extract value field
example:
$inbox = imap_open($hostname,$username,$password); if (!$inbox) { echo('cannot connect gmail: ' . imap_last_error()); exit; } $header_string = imap_fetchheader($inbox, 1); preg_match_all('/([^: ]+): (.+?(?:\r\n\s(?:.+?))*)\r\n/m', $header_string, $matches); $headers = array_combine($matches[1], $matches[2]); $xmailer = $headers['x-mailer']; imap_close($inbox);
Comments
Post a Comment