Connecting Tech Pros Worldwide Forums | Help | Site Map

PHP mailer with multi-form support

Newbie
 
Join Date: Apr 2007
Posts: 1
#1: Apr 8 '07
I am green to PHP and trying to create outside PHP mailer for html form ,i found the script i need but I can't get it to upload more than one file ,since i do not know exactly where to place script request for file2-file10 as well as the exact line to place extension control and size limit ,SOS , any help would be aprishiated

the mailer script:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])>7 ||
  3.          !strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']))
  4.          die("Bad referer");
  5. $form_fields=array_keys($HTTP_POST_VARS);$temp="Sender's IP Address: ".$_SERVER['REMOTE_ADDR']."\n";while($field = array_pop($form_fields)){$temp.="$field: $HTTP_POST_VARS[$field]\n";}$to=$_POST['To'];$from=$_POST['Email'];$message=$temp;$fileatt=$_FILES['File']['tmp_name'];$fileatt_type=$_FILES['File']['type'];$fileatt_name=$_FILES['File']['name'];$headers="From: $from";if(is_uploaded_file($fileatt)){$file=fopen($fileatt,'rb');$data=fread($file,filesize($fileatt));fclose($file);$semi_rand=md5(time());$mime_boundary="==Multipart_Boundary_x{$semi_rand}x";$headers.="\nMIME-Version: 1.0\n"."Content-Type: multipart/mixed;\n"." boundary=\"{$mime_boundary}\"";$message="This is a multi-part message in MIME format.\n\n"."--{$mime_boundary}\n"."Content-Type: text/plain;charset=\"UTF-8\"\n"."Content-Transfer-Encoding: 7bit\n\n".$message."\n\n";$data=chunk_split(base64_encode($data));$message.="--{$mime_boundary}\n"."Content-Type: {$fileatt_type};\n"." name=\"{$fileatt_name}\"\n"."Content-Transfer-Encoding: base64\n\n".$data."\n\n"."--{$mime_boundary}--\n";}
  6.  
  7. $ok=@mail($to,"YOUR COMANY OR NAME Form-Mail Message",$message,$headers);
  8. if(!$ok)header("location:domain goes here");
  9.  
  10. ?>
[Please use CODE tags when posting source code. Thanks! --pbmods]

ak1dnar's Avatar
Moderator
 
Join Date: Jan 2007
Location: Colombo
Posts: 1,440
#2: Apr 8 '07

re: PHP mailer with multi-form support


Next time read the posting guidelines. and wrap the code using CODE tags.
Newbie
 
Join Date: Jun 2007
Posts: 2
#3: Jun 2 '07

re: PHP mailer with multi-form support


you can download php mailer and here
Reply