Advanced Search

Results 1 to 2 of 2

Thread: issue attaching files to mail

  1. #1
    Join Date
    Jan 2010
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation issue attaching files to mail

    I am trying to attaching a file to my mail option and it isn't working lol.
    Here's my script:
    PHP Code:
    <?php
      $to
    '_@gmail.com';
      
      if(
    count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}
      
      
    $subject'Application';
      
    $from'Website';
      
    $fname $_REQUEST['fname'] ;
      
    $lname $_REQUEST['lname'] ;
      
    $phone $_REQUEST['phone'] ;
      
    $email $_REQUEST['email'] ;
      
    $state $_REQUEST['state'] ;
      
    $city $_REQUEST['city'] ;
      
    $about $_REQUEST['about'] ;
      
    $experience $_REQUEST['experience'] ;
       
    $fileatt      $_FILES['file1']['tmp_name'];     
      
    $fileatt_type $_FILES['file1']['type'];     
      
    $fileatt_name $_FILES['file1']['name'];
    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=\"iso-8859-1\"\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-Disposition: attachment;\n" .     
                 
    " filename=\"{$fileatt_name}\"\n" .     
                 
    "Content-Transfer-Encoding: base64\n\n" .     
                 
    $data "\n\n" .     
                 
    "--{$mime_boundary}--\n";     
      
      
    $bodystripslashes ('fname ' $fname ' lname ' $lname ' phone ' $phone ' email ' $email ' state ' $state ' city ' $city ' about ' $about ' experience ' $experience) ;
      
      
    mail$to$subject$body$message$headers$from );  
    ?><title>sendmail.php</title>

    Thank you for submitting your application! We will be contacting you shortly!
    I am currently getting: Parse error: syntax error, unexpected $end in /home/p153j78n/public_html/sendmail.php on line 48 (line 48 being the thank you... line)

    I don't know if the attach file works either, wasn't able to see if that worked yet. So if you see any issues please inform. Thanks a ton as always!

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    There is no second curly brace after the is_uploaded_file if statement:

    PHP Code:
    <?php
      $to
    '_@gmail.com';
      
      if(
    count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}
      
      
    $subject'Application';
      
    $from'Website';
      
    $fname $_REQUEST['fname'] ;
      
    $lname $_REQUEST['lname'] ;
      
    $phone $_REQUEST['phone'] ;
      
    $email $_REQUEST['email'] ;
      
    $state $_REQUEST['state'] ;
      
    $city $_REQUEST['city'] ;
      
    $about $_REQUEST['about'] ;
      
    $experience $_REQUEST['experience'] ;
       
    $fileatt      $_FILES['file1']['tmp_name'];     
      
    $fileatt_type $_FILES['file1']['type'];     
      
    $fileatt_name $_FILES['file1']['name'];
    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=\"iso-8859-1\"\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-Disposition: attachment;\n" .     
                 
    " filename=\"{$fileatt_name}\"\n" .     
                 
    "Content-Transfer-Encoding: base64\n\n" .     
                 
    $data "\n\n" .     
                 
    "--{$mime_boundary}--\n";     
      
      
    $bodystripslashes ('fname ' $fname ' lname ' $lname ' phone ' $phone ' email ' $email ' state ' $state ' city ' $city ' about ' $about ' experience ' $experience) ;
      
      
    mail$to$subject$body$message$headers$from );
    } else {
      echo 
    "No file uploaded.";
    }
    ?><title>sendmail.php</title>

    Thank you for submitting your application! We will be contacting you shortly!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •