#!/usr/bin/php
<?php
if (@dl($_SERVER['argv'][1]))
{
	$file = dirname(__FILE__).'/test.eml';
	$mime = mailparse_msg_parse_file($file);
	if (is_resource($mime))
	{
		$struct = mailparse_msg_get_structure($mime);
		if (sizeof($struct) == 3)
		{
			$section = mailparse_msg_get_part($mime, $struct[2]);
			if (is_resource($section))
			{
				ob_start();
				$result = mailparse_msg_extract_part_file($section, $file);
				$contents = ob_get_contents();
				ob_end_clean();				
				if ($result === true)
				{
					echo "MAILPARSE_OK";
				}	// if()
			}	// if()			
		}	// if()
	}	// if()	
}	// if()	
?>