//** load email class definition. function sendmsg($to, $subject, $msgtext, $from, $file, $type) { $fp = fopen($file,"rb"); $fcontent = fread($fp ,filesize($file)); fclose($fp); $content = chunk_split(base64_encode($fcontent)); $sep = strtoupper(md5(uniqid(time()))); $name = basename($file); $header = "From: $from\nReply-To: $from\n"; $header .= "MIME-Version: 1.0\n"; $header .= "Content-Type: multipart/mixed; boundary=$sep\n"; $body .= "--$sep\n"; $body .= "Content-Type: text/plain\n"; $body .= "Content-Transfer-Encoding: 8bit\n\n"; $body .= "$msgtext\n"; $body .= "--$sep\n"; $body .= "Content-Type: $type; name=\"$file\"\n"; $body .= "Content-Transfer-Encoding: base64\n"; $body .= "Content-Disposition: attachment; filename=\"$file\"\n"; $body .= "$content\n"; $body .= "--$sep--\n"; if (mail($to, $subject, $body, $header)) { return true; } else { return false; } }