Email Php

imap_searchstruct
imap_searchstruct -- Search the structure of a mime email message for a query string and return an array of the mime-parts that match all the criteria.
Description
array imap_searchstruct ( array struct, string query )
This will search the structure of a mail message as returned by the function imap_fetchstructure, and return an array of the parts that match all the query arguments. The returned array of parts are intended for use in imap_fetchbody function.
Example 1. imap_searchstruct() example
// Include the imap_fetchstruct.php file to add support for the function.
include (imap_searchstruct.php);
// Set up the server vars
$server = "mail.example.com";
$user = "example@example.com";
$password = "password";
// Initialize the mailserver connection.
$mserver = imap_open ("{" . $server . ":110/pop3}INBOX", $user, $password);
$nmsgs = imap_num_msg ($mserver);
for ($i = 1; $i <= $nmsgs; $i++)
{
// Fetch the structure for each message.
$struct = imap_fetchstructure ($mserver, $i);
// Perform the search. This query will return all the body text of an email.
$parts = imap_searchstruct ($struct, "type = '0' & subtype = 'plain' & disposition != 'attachment'");
// Fetch and echo the content of the first mime-part in the $parts array.
$body = imap_fetchbody ($mserver, $i, $parts[0]);
echo ($body);
}
// Cloes the mailserver connection.
imap_close ($mserver);
?>