Hi sir this is the contact from

echo $name=$_POST['name'];
echo $mail1=$_POST['mail'];
echo $website=$_POST['website'];
echo $title=$_POST['title'];
echo $des=$_POST['des'];
echo $swf=$_POST['swf'];//this is the attachment
echo $photo=$_POST['photo'];//this is the attachment
echo $Category=$_POST['Category'];

I want send all these details on email send me the mail function code in php Urgent

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

7 Years
Discussion Span
Last Post by Koseto

Hi , i wrote simple email form with attachment, but i receive message without attachment file :( uhh Here is code:

<html xmlns="http://www.w3.org/1999/xhtml">
<title>Mail with attachments</title>

function spamcheck($field)
  //filter_var() sanitizes the e-mail
  //address using FILTER_SANITIZE_EMAIL
  $field=filter_var($field, FILTER_SANITIZE_EMAIL);

  if(filter_var($field, FILTER_VALIDATE_EMAIL))
    return TRUE;
    return FALSE;
if (isset($_REQUEST['email'])) //if email is filled out, proceed
		//check if the email address is invalid
		if ($mailcheck==FALSE && $mailcheck2==FALSE)
				echo "Invalid input";
			$email = $_REQUEST['email'] ;
			$subject = $_REQUEST['subject'] ;
			$message = $_REQUEST['message'] ;
    		// boundary marker

   // now we'll build the message headers
   $headers = "From: $email\r\n" .
   "MIME-Version: 1.0\r\n" .
      "Content-Type: multipart/mixed;\r\n" .
      " boundary=\"{$mime_boundary}\"";

   // here, we'll start the message body.

   $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";

   if ((($_FILES["file"]["type"] == "application/msword")
|| ($_FILES["file"]["type"] == "application/pdf")
|| ($_FILES["file"]["type"] == "image/jpeg"))
&& ($_FILES["file"]["size"] < 20000000)) //20mb
   foreach($_FILES as $file){
      $tmp_name = $file['tmp_name'];
      $type = $file['type'];
      $name = $file['name'];
      $size = $file['size'];
      if (file_exists($tmp_name)){
            // open the file for a binary read
            $file = fopen($tmp_name,'rb');
            // read the file content into a variable
            $data = fread($file,filesize($tmp_name));

            // close the file
            // now we encode it and split it into acceptable length lines
            $data = chunk_split(base64_encode($data));

         $message .= "--{$mime_boundary}\n" .
            "Content-Type: {$type};\n" .
            " name=\"{$name}\"\n" .
            "Content-Disposition: attachment;\n" .
            " filename=\"{$fileatt_name}\"\n" .
            "Content-Transfer-Encoding: base64\n\n" .
         $data . "\n\n";
   // here's our closing mime boundary that indicates the last of the message
	echo "Invalid file format!";
   // now we just send the message
   if (@mail($recipient, "Subject: $subject", $message, $headers))
      echo "Message Sent";
      echo "Failed to send";
<form method="POST" name="email_form_with_attachments"
action="mail.php" enctype="multipart/form-data">
<label for='email'>From: </label>
<input type="text" name="email" ><br />

<label for='rmail'>To: </label>
<input type="text" name="rmail" ><br />
<label for='subject'>Subject: </label>
<input type="text" name="subject" ><br />
<label for='message'>Message:</label><br />
<textarea name="message" rows='15' cols='40'></textarea><br />
<label for='file'>Select A File To Upload:</label>
<input type="file" name="file"><br />
<input type="submit" value="Submit" name='submit'>
<?php }?>

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.