Try this one. It works fine.
<?
// ************************************
// E-mail functions (binary attachment)
// ************************************
function m_attach_bin( $to_fname, $subject_ftext, $message, $from, $type )
{
static $hold_to= "";
static $hold_subject= "";
static $hold_from= "";
static $hold_message= "";
static $boundary= "-----------------kjbsdf9873987348735";
$MIME= "MIME-Version: 1.0\nContent-Type: multipart/mixed;\n\tboundary=\"$boundary\"\n\nThis is a multi-part message in MIME format.\n\n";
$startMsg= "\n--$boundary\nContent-Type: text/plain;\n\tcharset=\"iso-8859-1\"\nContent-Transfer-Encoding: 8bit\n\n";
$ending= "\n--$boundary--";
if ( $to_fname== "" ) /* send it! */
{
$hold_message=$hold_message . $ending;
return( mail( $hold_to, $hold_subject, $hold_message, $hold_from ) );
}
elseif ( $message== "" ) /* we must be attaching a file */
{
$hold_message=$hold_message . "\n--$boundary\nContent-Type: image/".$type. ";\n\tname=\"$to_fname\"\nContent-Transfer-Encoding: base64\nContent-Disposition: inline;\n\tfilename=\"$to_fname\"\n\n$subject_ftext";
}
else /* starting a new message */
{
$hold_to=$to_fname;
$hold_subject=$subject_ftext;
$hold_message=$startMsg . $message. "\n\n";
$hold_from= "From: $from\n$MIME\n";
}
};
function m_attach_file_bin( $shortname, $longname, $type )
{
$fp=fopen($longname, "r");
$in = fread( $fp, filesize( $longname ) );
fclose( $fp );
$out= chunk_split(base64_encode($in));
return( m_attach_bin( $shortname, $out, "", "", $type ) );
};
function m_attach_send_bin($type)
{
return( m_attach_bin( "", "", "", "", $type ) );
};
$dest_email="dest. email address";
$title="MIME TEST mail2";
$message_to_send="Another MIME Test with *.png";
$from="sender email address";
$type="extention e.g. png";
$filename="filename with extention";
$path="complete path including filename";
m_attach_bin($dest_email, $title, $message_to_send, $from, $type);
m_attach_file_bin($filename, $path, $type);
m_attach_send_bin($type);
?>