Code: Select all
<?php
$to = someone@gmail.com";
$att = $_FILES['att'];
$att_path = $_FILES['att']['tmp_name'];
$att_name = $_FILES['att']['name'];
$att_size = $_FILES['att']['size'];
$att_type = $_FILES['att']['type'];
$att2 = $_FILES['att2'];
$att2_path = $_FILES['att2']['tmp_name'];
$att2_name = $_FILES['att2']['name'];
$att2_size = $_FILES['att2']['size'];
$att2_type = $_FILES['att2']['type'];
$fp = fopen( $att_path, "rb");
$file = fread( $fp, $att_size );
fclose ($fp);
$fp2 = fopen( $att2_path, "rb");
$file2 = fread( $fp2, $att2_size );
fclose ($fp2);
$num = md5(time());
$str = "==multipart_Boundary_x{$num}x";
$file = chunk_split(base64_encode($file));
$subject = "You have a new order from " . $_REQUEST['order_company_name'];
$email = $_REQUEST['order_email'] ;
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: multipart/mixed;";
$headers .= "boundary=\"{$str}\"\r\n";
$headers .= "From: $email";
$msg .= "This is a multi-part message in MIME format\r\n\n";
$msg .= "--{$str}\r\n";
$msg .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$msg .= "Content-Transfer-Encoding: 8bit\r\n";
$msg .= "--{$str}\r\n";
$msg .= "Content-Type: {$att_type}; ";
$msg .= "name=\"{$att_name}\"\r\n";
$msg .= "Content-Disposition: attachment; ";
$msg .= "filename =\"{$att_name}\"\r\n";
$msg .= "Content-Transfer-Encoding: base64\r\n";
$msg .= "$file\r\n\n";
$msg .= "--{$str}";
$msg .= "Content-Type: {$att2_type}; ";
$msg .= "name=\"{$att2_name}\"\r\n";
$msg .= "Content-Disposition: attachment; ";
$msg .= "filename =\"{$att2_name}\"\r\n";
$msg .= "Content-Transfer-Encoding: base64\r\n";
$msg .= "$file2\r\n\n";
$msg .= "--{$str}";
$sent = mail($to, $subject, $msg, $headers) ;
if($sent)
{print "Thank you. Your order was sent successfully"; }
else
{print "Sorry. We encountered an error sending your mail"; }
?>