Re: Attachements

From: Date: Sat, 24 Aug 2002 12:22:17 +0000
Subject: Re: Attachements
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-114115@lists.php.net to get a copy of this message
"Oliver Witt" <oliverwitt@t-online.de> ???????/???????? ? ???????? ?????????: news:3D673047.F9FCA733@t-online.de... > Hi, > Can you attach files to emails and send them through a php script? If > so, how? > Kind regards, > Oliver > You can use this function. It can attach just one file. $mode = message type: plain (default) or HTML otherwise function SendMail($email,$subject,$body,$from="",$mode="plain",$file_name="",$file_ty pe="",$no_template=0) { $body_prefix=""; $body_suffix=""; $from_suffix=""; if(!empty($file_name)) { $file=fopen($file_name,"r"); if($file) { $file_content=""; while(!feof($file)) $file_content.=fread($file,4096); fclose($file); $file_name=basename($file_name); $body_prefix="This is a multi-part message in MIME format. ------Part012345678 Content-Type: text/$mode; charset=\"ISO-8859-1\" "; $body_suffix=" ------Part012345678 Content-Type: ".( empty($file_type) ? "application/octet-stream" : $file_type )."; name=\"$file_name\" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=\"$file_name\" ".chunk_split(base64_encode($file_content))." ------Part012345678-- "; $from_suffix=" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=\"----Part012345678\""; } } else { $from_suffix=" MIME-Version: 1.0 Content-Type: text/$mode; charset=\"ISO-8859-1\""; } $result=@mail(trim($email),trim($subject),$body_prefix.$body.$body_suffix,"F rom: ".$from.$from_suffix); return $result; } WBR, Mike Tsapenko Chief of Web-development Dept. AlarIT http://www.AlarIT.com

« previous php.general (#114115) next »