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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.