mbeals Posted November 13, 2007 Share Posted November 13, 2007 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.