Jump to content

email attachment help


aladiyat23

Recommended Posts

I'm trying to send email with attachment from my php file. The message is delivered fine but I'm only getting the path to the file on the senders computer.

I've copied my php and the email body...

[color=green]email body:[/color]
  From: [email protected]

  Dealer Name: asdf

  Address: asdf

  Zip: asdf

  Quanity: asdf

  List: Regular Auto

  Range:

  Year: asdf

  Make: asdf

  Other:

  D:\Program Files\XMPie\XMPie uImage\uImageOutput\DMMI

[color=green]my php:[/color]

<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){

  $to = "[email protected]";
  $subject = "Data Request";
  $email = $_POST['requiredemail'];
  $dname = $_POST['requireddealername'];
  $address = $_POST['requiredaddress'];
  $zip = $_POST['requiredzip'];
  $quanity = $_POST['requiredquanity'];
  $list = $_POST['requiredlist'];
  $range = $_POST['range'];
  $year = $_POST['year'];
  $make = $_POST['make'];
  $other = $_POST['other'];
 
  $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
 
  $tmp_name = $_FILES['uploadedfile']['tmp_name'];
  $type = $_FILES['uploadedfile']['type'];
  $name = $_FILES['uploadedfile']['name'];
  $size = $_FILES['uploadedfile']['size'];
 
  $message = "
  From: $email\n
  Dealer Name: $dname\n
  Address: $address\n
  Zip: $zip\n
  Quanity: $quanity\n
  List: $list\n
  Range: $range\n
  Year: $year\n
  Make: $make\n
  Other: $other\n";
 
  if (file_exists($tmp_name)){
  if(is_uploaded_file($tmp_name)){
  $file = fopen($tmp_name,'rb');
  $data = fread($file,filesize($tmp_name));
  fclose($file);
 
  $data = chunk_split(base64_encode($data));
}

  $headers = "From: $email\r\n" .
  "MIME-Version: 1.0\r\n" .
  "Content-Type: multipart/mixed;\r\n" .
  " boundary=\"{$mime_boundary}\"";

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

  $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" .
  "--{$mime_boundary}--\n";

if (@mail($to, $subject, $message, $headers))
    echo '<META HTTP-EQUIV="REFRESH" CONTENT="1;URL=http://www.dmmipromotions.com/submission.html">';
else
echo "An error has occured. Please fill out the form and try again";
  }
} else {
?>

Can anyone help me with this?
Link to comment
https://forums.phpfreaks.com/topic/15518-email-attachment-help/
Share on other sites

Maybe I should rephrase my question...

I'm trying to receive email with an attachment from a php form. I'm getting the message along with the senders path to their file they attempted to send.

Does anyone know of any known solutions or what part of the script would cause this?

Thanks :)
Link to comment
https://forums.phpfreaks.com/topic/15518-email-attachment-help/#findComment-63087
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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