Jump to content

ceggik

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ceggik's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This what i did, the only problem with it now is that it is sending 2 email each with one attachment. Is there a way we can have both coming into one email? <?php if(isset($_POST['send'])) { $fileatt_one = $_FILES['attachment']['tmp_name'][0]; $fileatt_type_one = "application/octet-stream"; // File Type $fileatt_name_one = $_FILES['attachment']['name'][0]; // Filename that will be used for the file as the attachment $fileatt_two = $_FILES['attachment']['tmp_name'][1]; $fileatt_type_two = "application/octet-stream"; // File Type $fileatt_name_two = $_FILES['attachment1']['name'][1]; // Filename that will be used for the file as the attachment $email_from = "gikera@itura.net"; // Who the email is from $email_subject = "Test"; // The Subject of the email $email_txt = "Testing 123"; // Message that the email has in it $email_to = "admin@itura.net"; // Who the email is too $headers = "From: ".$email_from; $file_one = fopen($fileatt_one,'rb'); $data_one = fread($file_one,filesize($fileatt_one)); fclose($file_one); $file_two = fopen($fileatt_two,'rb'); $data_two = fread($file_two,filesize($fileatt_two)); fclose($file_two); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $data_one = chunk_split(base64_encode($data_one)); $data_two = chunk_split(base64_encode($data_two)); $headers .= "\nMIME-Version: 1.0\n" ."Content-Type: multipart/mixed;\n" ." boundary=\"{$mime_boundary}\""; $email_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" .$email_txt . "\n\n"; $email_message .= "--{$mime_boundary}\n" ."Content-Type: {$fileatt_type_one};\n" ." name=\"{$fileatt_name_one}\"\n" ."Content-Transfer-Encoding: base64\n\n" .$data_one . "\n\n" ."--{$mime_boundary}--\n"; $email_message .= "--{$mime_boundary}\n" ."Content-Type: {$fileatt_type_two};\n" ." name=\"{$fileatt_name_two}\"\n" ."Content-Transfer-Encoding: base64\n\n" .$data_two . "\n\n" ."--{$mime_boundary}--\n"; $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) { echo "<font face=verdana size=2>The file was successfully sent!</font>"; } else { die("Sorry but the email could not be sent. Please go back and try again!"); } } ?> <form enctype="multipart/form-data" name="send" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <input type="file" name="attachment[]" size="50" /><br> <input type="file" name="attachment1[]" size="50" /><br> <input type="submit" name="send" value="Submit"> </form>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.