Re: Attachements

From: Date: Sat, 24 Aug 2002 12:06:15 +0000
Subject: Re: Attachements
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-113928@lists.php.net to get a copy of this message
Hi: the following is my easy way to send MIME mail with a attach files. It worked for my own mailing system. //-----------Make sure if a file upload or not... if(!empty($my_file)) { copy($my_file,"files/$my_file_name"); $fp=fopen("files/$my_file_name","r"); //---------------------------------------compose the MIME $version="MIME-Version: 1.0 \n"; //declair the version $boundary ="b".md5(uniqid(time())); //make the boundary $body_message=$content.$bottom."\n\n--$boundary \n"; $my_add_file="Content-Type: ".$my_file_type.";\n name=\"".$my_file_name."\"\n". "Content-Disposition: attachment; \n filename=\"$my_file_name\" \n". "Content-Transfer-Encoding: base64 \n\n"; $the_file_content= chunk_split(base64_encode(fread ($fp,filesize("files/$my_file_name")))); //use base64 method to encode the file. $my_add_file .= $the_file_content; //the file content added. //---------------------------------------- $the_part="Content-Type: multipart/mixed; ". "boundary = $boundary \n\n". "This is a MIME encoded mesaage. \n\n-- $boundary\n\n"; $the_part2="Content-Type: multipart/alternative; ". " boundary = $boundary ". " \n\n--$boundary"; $mime .="From: ".$main_address."\n"; $mime .="Cc: ".$other_address."\n"; $mime .=$version; $mime .=$the_part; $mime .=$body_message; $mime .=$my_add_file; $mime .="--$boundary-- \n"; mail($main_address,$title,"",$mime); ?> <script> alert("you succeed to send a MIME mail"); location.href="list.php"; </script> <? exit; } ----------------------------------------------------- This mail sent through IMP: http://web.horde.org/imp/

« previous php.general (#113928) next »