Jump to content

mailparse_msg_get_structure returning single valued array


mbeals

Recommended Posts

I am writing code to strip out and write key data to a database from incoming e-mail.  I am using the mailparse functions to handle the incoming mail.  My code pulls in the e-mail fine, but the array returned by the mailparse_msg_get_structure() only has one row.  The entire contents of the /var/mail/$user file is being put into one row instead of it being broken apart into individual messages.  Here is the code I'm using:

 

$filename = "/var/mail/helpdesk";

$mime = mailparse_msg_parse_file($filename);

$struct = mailparse_msg_get_structure($mime);

echo count($struct);

echo "<table>\n";
foreach($struct as $st) {
        echo "<tr>\n";

        echo "<td><a href=\"$PHP_SELF?showpart=$st\">$st</a></td>\n";

        $section = mailparse_msg_get_part($mime, $st);
        $info = mailparse_msg_get_part_data($section);

        echo "\n";
        echo "<td>" . $info["content-type"] . "</td>\n";
        echo "<td>" . $info["content-disposition"] . "</td>\n";
        echo "<td>" . $info["disposition-filename"] . "</td>\n";
        echo "<td>" . $info["charset"] . "</td>\n";
        echo "</tr>";
}
echo "</table>";

 

This simply returns:

 

1 text/plain us-ascii

 

 

If you extract the contents with mailparse_msg_get_part() and echo it, it just returns all the e-mails lumped together.

 

What do I need to do to get mailparse to recognize the individual messages?

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.