Jump to content

IMAP - retrieving certain headers


rizla_za

Recommended Posts

Hi Guys and Girls.

 

IMAP - retrieving certain headers

I need some help pls, I'm writing a small script to check and retrieve only mail sent by an specific person.

My code is as follow.

 

<?php
$mbox = imap_open("{myserver:143}", "username", "password");
echo "<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($mbox);

if ($headers == false) {
   echo "Call failed<br />\n";
} else {
   foreach ($headers as $val) {
       echo $val . "<br />\n";
   }
}

imap_close($mbox);

?>

 

This works fine when retrieving all messages out of the mailbox. But I want only messages from a certain person so I added.

 

$mbox_search = imap_search($mbox,'FROM "$person"');
foreach ($mboxsearch as $val) {
echo "
$val
";
}

 

$val now holds the message_number of all the mail sent by $person, my question is how do I get the headers from only those mail? imap_headers do not have the parameter for message_number and imap_fetchheader return way more than just the header.

 

Thanks for the help.

Link to comment
https://forums.phpfreaks.com/topic/95804-imap-retrieving-certain-headers/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.