Jump to content

Recommended Posts

This code is for a php form that send an email but the thing is that it s not sending the attchement.

So i am asking id anyone could help

Ramzy

 

 

<?php

 

$to = 'info@-------.com' ;

$from = $_REQUEST['email'] ;

$name = $_REQUEST['fn'] ;

$headers = "From: $from";

$subject = "Design Competition Information";

 

foreach($_POST['checkbox'] as $value) {

$check_msg .= "I choosed: $value\n";

}

 

 

$fileatt = $_FILES['attach']['tmp_name'];

$fileatt_type = $_FILES['attach']['type'];

$fileatt_name = $_FILES['attach']['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}\"";

 

$subject = "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" .

$subject . "\n\n";

 

$data = chunk_split(base64_encode($data));

 

$subject .= "--{$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";

}

 

$fields = array();

$fields{"fn"} = "fn";

$fields{"ln"} = "ln";

$fields{"Gender"} = "Gender";

$fields{"university"} = "university";

$fields{"major"} = "major";

$fields{"tel"} = "tel";

$fields{"email"} = "email";

$fields{"address"} = "address";

$fields{"select"} = "select";

$fields{"comments"} = "comments";

$fields{"check_msg"} = "$check_msg";

 

 

$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

 

 

 

$headers2 = "From: info@----.com";

$subject2 = "Thank you for contacting us";

$autoreply = "Thank you for contacting us.

Somebody will get back to you as soon as possible, please consult our website at www.-------.com";

 

if($from == '') {print "You have not entered an email, please go back and try again";}

else {

if($name == '') {print "You have not entered a name, please go back and try again";}

else {

$send = mail($to, $subject, $body, $headers);

$send2 = mail($from, $subject2, $autoreply, $headers2);

if($send)

{header( "Location: http://www.-----.php" );}

else

{print "We encountered an error sending your mail, please notify info@-----.com"; }

}

}

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.