$strInfo=""; include ('address.php'); if (isset($_POST['action']) && $_POST['action'] == 'submitcontact') { $toEmail="lise@mp2design.com"; $toName="Lise"; $email=$_REQUEST['email']; $company=$_REQUEST['company']; $firstname=$_REQUEST['firstname']; $lastname=$_REQUEST['lastname']; $phone=$_REQUEST['phone']; $request=$_REQUEST['request']; $subject="Business Request"; $projectdetails=$_REQUEST['projectdetails']; $message="Name: $firstname"." $lastname\n"; $message=$message."Phone: $phone\n"; $message=$message."Company: $company\n"; $message=$message."Email: $email\n"; $message=$message."Request: $request\n\n\n"; $message=$message."Message:\n$projectdetails"; $ATTM=$_REQUEST['upload_file']; function xmail($email_address,$email_from,$subject,$msg,$attach_filepath) { $mail_attached = ""; $boundary = md5(uniqid(time(),1))."_xmail"; if (!empty($attach_filepath)) { if ($fp = fopen($attach_filepath,"rb")) { $file_name = basename($attach_filepath); $content = fread($fp,filesize($attach_filepath)); $mail_attached .= "--".$boundary."\r\n" ."Content-Type: image/jpeg; name=\"$file_name\"\r\n" . "Content-Transfer-Encoding: base64\r\n" . "Content-Disposition: inline; filename=\"$file_name\"\r\n\r\n" .chunk_split(base64_encode($content))."\r\n"; fclose($fp); } else { $strInfo ="There has been error in attaching files."; } $mail_attached .= "--".$boundary." \r\n"; $add_header ="MIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"$boundary\""; $mail_content = "--".$boundary."\r\n" . "Content-Type: text/plain; charset=iso-8859-1; format=flowed\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n" . $msg."\r\n\r\n".$mail_attached; return mail($email_address,$subject,$mail_content,"From: ".$email_from."\r\n".$add_header); } else { return mail($email_address,$subject,$msg,"From: ".$email_from); } } $result=xmail($toEmail,$email,$subject,$message,$ATTM); if($result) { $strInfo =$strInfo."Message has been successfully sent."; } else { $strInfo =$strInfo."Error in sending mail."; } } ?>