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?

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.