Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-21-2005, 12:19 AM
WebProWorld Member
 

Join Date: Sep 2004
Location: Thailand
Posts: 92
I am Nick RepRank 0
Default PHP mail form, include images

I have a basic form that looks like below. I would like to include the feature an image attachment as well. I have seacrhed the net but came out with nothing I could grip. Note I am not a programmer.

I would appreciate any assistance in moving this project further. / Cheers Nick


This is how it looks today!

<?

// ===========modification by your own===================
$timenow=date("Y-m-d H:i:s");
$sender_name=$your_name; // you can change value in quotation
$sender_email=$your_email;
$receiver_email="$receiver_email";
$subject="$subject";
$message=" Time of submit: $timenow
$subject
$hiddenmessage

Details of enquirier:
$your_name
$company
$your_email
$phone_number
$country

Details of inquiry:
$item_spec
$quantity
$size_item

Decoration (if any):
$decoration
$size_decoration

$target_price
$pref_shipment";


//================================================== =======

$headers= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=ISO-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: \"".$sender_name."\" <".$sender_email.">\n";



// Aun Note
// Note that the two headers "X-Priority" and "X-MSMail-Priority", can be left out..
// ..but they will help overcome some of the more aggressive spam filtering systems
// ie. (hotmail, yahoo mail, ...) and ensures your mail is delivered.

if (mail("\"".$receiver_name."\" <".$receiver_email.">", $subject, $message, $headers)) {
$result_sendemail="Your request has been received. Thank you!";
} else {
$result_sendemail="<font color='#FF0000'>Your attempt contact us failed, please try again or contact directly trough sales@mydomain.com!</font>";
}

echo "(Sending status: $result_sendemail)
";

?>
Reply With Quote
  #2 (permalink)  
Old 02-21-2005, 12:43 AM
Deep13's Avatar
WebProWorld Veteran
 

Join Date: Dec 2003
Location: India
Posts: 306
Deep13 RepRank 0
Default

I think you have to copy the image to some temporary location first and then attache it to the mail...

I had done similar thing but the attachment type was doc..

here is part of the code that I had used..this might help you..


Code:
// copy the file to folder
copy ($_FILES['resume']['tmp_name'], $upload_path.$file_name);

// Read the file
$file_with_path = $upload_path.$file_name;
$handle = fopen($file_with_path, "rb");
$fileContent = fread($handle, filesize($file_with_path));
fclose($handle);

// format $data using RFC 2045 semantics
$fileContent = chunk_split(base64_encode($fileContent));

// Generate a boundary string
$boundary = strtoupper(md5(uniqid(time())));

// Generate a headers
$headers .= "From: $f_name<$email>\n";
$headers .= "X-Sender: <$email>\n";
$headers .= "X-Mailer: Careers\n"; 
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <$email>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed;"."name=$file_with_path;" ." boundary=\"$boundary\"\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "Content-Disposition: attachment\n";

// To and Subject for the mail
$to = "email@example.com";

$subject="Your subject here";

// Get sender's IP Address
$ip = getenv(REMOTE_ADDR);

// Generate a message body
$body .= "This is a multi-part message in MIME format.\r\n";
$body .= "\r\n";
$body .= "--".$boundary."\r\n";
$body .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$body .= "Content-Transfer-Encoding: 7bit\r\n";
$body .= "\r\n";
$body .= "---------------------------\r\n\n";
$body .= "Name : $f_name\r\n\n";
$body .= "Email : $email\r\n\n";
$body .= "Applying for : $position\r\n\n";
$body .= "Message (if any) : $msg\r\n\n";
$body .= "Please check attached file \"$file_name\" for the resume. \r\n\n";
$body .= "---------------------------\r\n";
$body .= "Sender's IP Address : $ip \r\n";
$body .= "---------------------------\r\n";
$body .= "--".$boundary."\r\n";
$body .= "Content-Type: applications/msword;\r\n";
$body .= " name=\"".$file_name."\"\r\n";
$body .= "Content-Transfer-Encoding: base64\r\n";
$body .= "Content-Disposition: attachment;\r\n";
$body .= " filename=\"".$file_name."\"\r\n";
$body .= "\r\n";
$body .= $fileContent;
$body .= "\r\n";
$body .= "--".$mime_boundary."\r\n";

// Send mail
mail ($to,$subject,$body,$headers);

// Ok mail sent, delete the file now..
@unlink($file_with_path);
header ("Location: thanks.php");
You may apply the same logic and instead of doc using your file type...

I hope this helps you.
Deep
Reply With Quote
  #3 (permalink)  
Old 02-21-2005, 01:07 AM
WebProWorld Member
 

Join Date: Sep 2004
Location: Thailand
Posts: 92
I am Nick RepRank 0
Default

Thanks! I will try to work this out. I was hopening I could just attach but now I understand I first have to upload to temperary location

Cheers Nick
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0