-1

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.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Koseto
0

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">
<head>
<title>Mail with attachments</title>
</head>

<body>
<?php
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;
    }
  else
    {
    return FALSE;
    }
  }
if (isset($_REQUEST['email'])) //if email is filled out, proceed
	{
		//check if the email address is invalid
		$mailcheck=spamcheck($_REQUEST['email']);
		$mailcheck2=spamcheck($_REQUEST['rmail']);
		
		if ($mailcheck==FALSE && $mailcheck2==FALSE)
			{
				echo "Invalid input";
			}
			else
			{
			$email = $_REQUEST['email'] ;
			$recipient=$_REQUEST['rmail'];
			$subject = $_REQUEST['subject'] ;
			$message = $_REQUEST['message'] ;
			
    		// boundary marker
   $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";

   // 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=$message;

   $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)){
         if(is_uploaded_file($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
            fclose($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
   $message.="--{$mime_boundary}--\n";
   }
   else{ 
	echo "Invalid file format!";
	}
   // now we just send the message
   if (@mail($recipient, "Subject: $subject", $message, $headers))
      echo "Message Sent";
   else
      echo "Failed to send";
	} 
}
else 
	{
?>
<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'>
</form>
<?php }?>
</body>
</html>

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.