Results 1 to 3 of 3

Thread: attach file in form and send it via email, email message body=included php file

  1. #1
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default attach file in form and send it via email, email message body=included php file

    At last I make it to send email attachment of submited file with an included file php as message body, but after three tries and success emails with attachments came, NOW come an email only with nothing in , reads as:
    "
    -----Original Message-----
    From: tid123akh76@p3slh141.shr.phx3.secureserver.net [mailto:tid123akh76@p3slh141.shr.phx3.secureserver.net]
    Sent: Tuesday, May 27, 2008 11:55 PM
    To: info@ancientgreekdramainstitute-cyprus.org; ancientgreekdramainstitute@yahoo.com; lse@world-marketinghome.com
    Subject: Apply for the Professional Session www.ancientgreekdramainstitute-cyprus.org

    "
    you may try at http://www.ancientgreekdramainstitut...g/apply-mf.htm to come to you the email rather than one with attachment(to the email you insert in form)...
    form processor(apply-iti-processor2.php):
    Code:
    <?php
    // session_start(); // start up your PHP session! 
    /* recipients */
    // $to = "lse@world-marketinghome.com"; 
    // $to = "info@polis-index.com.cy"; 
    $subject = "Apply for the Professional Session www.ancientgreekdramainstitute-cyprus.org"; 
    $radiobutton = $_POST['radiobutton'];
    $title = $_POST['title'];
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone_day = $_POST['phone_day1'];
    $phone_evening = $_POST['phone_evening1'];
    $country = $_POST['country'];
    $message3 = $_POST['message'];
    
    $fax = $_POST['fax'];
    $address = $_POST['address'];
    $city = $_POST['city'];
    // $cv = $_POST['fileatt'];
    //$cv = $fileatt_name;
    // Obtain file upload vars
    $fileatt      = $_FILES['fileatt']['tmp_name'];
    $fileatt_type = $_FILES['fileatt']['type'];
    $fileatt_name = $_FILES['fileatt']['name'];
    
    
    
    $to = "info@ancientgreekdramainstitute-cyprus.org,ancientgreekdramainstitute@yahoo.com,{$email}";   // info@polis-realestate.eu 
    
    // --------------------------------------
    //include_once ("confirm-apply-si.php"); 
    $ok = @mail($to, $subject, $message, $headers);
    if ($ok) {
      include_once ("confirm-apply-si.php"); 
    } else {
      echo "<p>Mail could not be sent. Sorry!</p>";
    }
    ob_start();
    include('confirm-apply-si.php');
    $message2 = ob_get_clean();
    /*
    ob_start();
    include('confirm-contactus.php');
    $message_customer = ob_get_clean();
    */
    $headers = "From:info@ancientgreekdramainstitute-cyprus.org";                     
    // $headers .= "\nBcc:info@Polis-RealEstate.eu"
    $headers .= "\nReply-To:info@ancientgreekdramainstitute-cyprus.org"; 
    // $headers .= "\nContent-Type: text/html; charset=UTF-8";
    // $headers .= "\nMIME-Version: 1.0";  
    if (is_uploaded_file($fileatt)) {
      // Read the file to be attached ('rb' = read binary)
      $file = fopen($fileatt,'rb');
      $data = fread($file,filesize($fileatt));
      fclose($file);
    
      // Generate a boundary string
      $semi_rand = md5(time());
      $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
      
      // Add the headers for a file attachment
      $headers .= "\nMIME-Version: 1.0\n" .
                  "Content-Type: multipart/mixed;\n" .
                  " boundary=\"{$mime_boundary}\"";
    
      // Add a multipart boundary above the plain message
      $message = "This is a multi-part message in MIME format.\n\n" .
                 "--{$mime_boundary}\n" .
                 "Content-Type: text/html; charset=\"iso-8859-1\"\n" .
                 "Content-Transfer-Encoding: 7bit\n\n" .
                 $message2 . "\n\n";
    
      // Base64 encode the file data
      $data = chunk_split(base64_encode($data));
    
      // Add file attachment to the message
      $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";
    }
    // mail($email,$subject,$message_customer,$headers); 
    
    // mail($to,$subject,$message,$headers); 
    // Send the message
    
    ?>

    how I print to the confirm form submission screen(php file INCLUDED) the name and directory of the submitted file in visitor's PC(URL) ?
    I can send any file size ? how I set max limit ?

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Email this person and make sure that when he submitted the forum that there were no problems. I didn't take a look at the code. But if you didn't change anything or update anything. It should work.
    Jeremy | jfein.net

  3. #3
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    problem fixed, one last point...
    how I print to the confirm form submission screen(php file INCLUDED <?= $fileField; ?>) the name and directory of the submitted file in visitor's PC(URL) ?
    I can send any file size as attachment ? how I set max limit (attached file) ? To send any file type, I do not refer to individual files just leave it simple, just this ?

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
  •