2014-01-26 35 views
0

我在我的網站上在線提交物業面積讓用戶可以在圖片中的文字的形式發送性能,以我的電子郵件地址:圖片不能發送到收件箱,使用PHP的mail()

但我沒有收到圖像。我只收到文字。我想弄清楚爲什麼會發生這種情況,但是我找不到任何會導致這種情況的事情。有人可以幫我找出問題嗎?

代碼:

<?php 
if (isset($_POST['propertystatus'])) { 
    // EDIT THE 2 LINES BELOW AS REQUIRED 
    $email_to    = "[email protected]"; 
    $email_subject   = "New Property From Customer"; 
    $email_subject_to_user = "Copy of your email"; 
    $propery_Information = 'PROPERTY INFORMATION'; 
    $propery_Location  = 'PROPERTY LOCATION'; 
    $contact_Information = 'CONTACT INFORMATION'; 
    function died($error) 
    { 
    // your error code can go here 
    echo "We are very sorry, but there were errors found with the form you submitted.<br>"; 
    echo $error . "<br />"; 
    die(); 
    } 
    // validation expected data exists 
    if (!isset($_POST['propertystatus']) || !isset($_POST['currencytype']) || !isset($_POST['currency']) || !isset($_POST['rooms']) || !isset($_POST['bathroom']) || !isset($_POST['kitchen']) || !isset($_POST['yard']) || !isset($_POST['housedesproperty']) || !isset($_POST['drop_1']) || !isset($_POST['drop_2']) || !isset($_POST['drop_3']) || !isset($_POST['region']) || !isset($_POST['street']) || !isset($_POST['name']) || !isset($_POST['emailadd']) || !isset($_POST['conemailadd']) || !isset($_POST['phone1']) || !isset($_POST['phone2']) || !isset($_FILES['uploadimages'])) { 
    died('You have not properly selected the fields.'); 
    } 
    // start code of attachement 
    if (empty($_FILES['uploadimages']['name'])) { 
    echo 'You have\'nt Entered Value for upload field'; 
    exit(); 
    } else { 
    $attachment  = $_FILES['uploadimages']['tmp_name']; 
    $attachment_name = $_FILES['uploadimages']['name']; 
    if (is_uploaded_file($attachment)) { 
     $fp = fopen($attachment, "rb"); 
     $data = fread($fp, filesize($attachment)); 
     $data = chunk_split(base64_encode($data)); 
     fclose($fp); 
    } 
    $headers = "From: $email<$email>\n"; 
    $headers .= "Reply-To: <$email>\n"; 
    $headers .= "MIME-Version: 1.0\n"; 
    $headers .= "Content-Type: multipart/related; type=\"multipart/alternative\"; boundary=\"----=MIME_BOUNDRY_main_message\"\n"; 
    $headers .= "X-Mailer: PHP4\n"; 
    $headers .= "X-Priority: 3\n"; 
    $headers .= "Return-Path: <$email>\n"; 
    $headers .= "This is a multi-part message in MIME format.\n"; 
    $headers .= "------=MIME_BOUNDRY_main_message \n"; 
    $headers .= "Content-Type: multipart/alternative; boundary=\"----=MIME_BOUNDRY_message_parts\"\n"; 
    $message = "------=MIME_BOUNDRY_message_parts\n"; 
    $message .= "Content-Type: text/html; charset=\"utf-8\"\n"; 
    $message .= "Content-Transfer-Encoding: quoted-printable\n"; 
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_message_parts--\n"; 
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_main_message\n"; 
    $message .= "Content-Type: application/octet-stream;\n\tname=\"" . $attachment_name . "\"\n"; 
    $message .= "Content-Transfer-Encoding: base64\n"; 
    $message .= "Content-Disposition: attachment;\n\tfilename=\"" . $attachment_name . "\"\n\n"; 
    $message .= $data; //The base64 encoded message 
    $message .= "\n"; 
    $message .= "------=MIME_BOUNDRY_main_message--\n"; 
    mail($email_to, $email_subject, $message, $headers); 
    } 
    // end code of attachment 
    $property_status = $_POST['propertystatus']; // required 
    $currency_type = $_POST['currencytype']; // required 
    $currency   = $_POST['currency']; // required 
    $rooms   = $_POST['rooms']; // required 
    $bathroom   = $_POST['bathroom']; // required 
    $kitchen   = $_POST['kitchen']; // required 
    $yard    = $_POST['yard']; // required 
    $housedesproperty = $_POST['housedesproperty']; // required 
    $drop_1   = $_POST['drop_1']; // required 
    $drop_2   = $_POST['drop_2']; // required 
    $drop_3   = $_POST['drop_3']; // required 
    $region   = $_POST['region']; // required 
    $street   = $_POST['street']; // required 
    $name    = $_POST['name']; // required 
    $emailadd   = $_POST['emailadd']; // required 
    $conemailadd  = $_POST['conemailadd']; // required 
    $phone1   = $_POST['phone1']; // required 
    $phone2   = $_POST['phone2']; // required 
    $error_message = ""; 
    $email_exp  = '/^[A-Za-z0-9._%-][email protected][A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; 
    if (!preg_match($email_exp, $emailadd) && !preg_match($email_exp, $conemailadd)) { 
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; 
    } 
    $email_message = "Property details below.\n\n"; 
    function clean_string($string) 
    { 
    $bad = array(
     "content-type", 
     "bcc:", 
     "to:", 
     "cc:", 
     "href" 
    ); 
    return str_replace($bad, "", $string); 
    } 
    $email_message .= "" . clean_string($propery_Information) . "\n"; 
    $email_message .= "--------------------------------------------" . "\n"; 
    $email_message .= "Property Status: " . clean_string($property_status) . "\n"; 
    $email_message .= "Total Price: " . clean_string($currency_type) . " " . (number_format($currency, 2, '.', ',')) . "\n"; 
    $email_message .= "Rooms: " . clean_string($rooms) . "\n"; 
    $email_message .= "Bathrooms: " . clean_string($bathroom) . "\n"; 
    $email_message .= "Bathrooms: " . clean_string($kitchen) . "\n"; 
    $email_message .= "Bathrooms: " . clean_string($yard) . "\n"; 
    $email_message .= "Description: " . clean_string($housedesproperty) . "\n\n"; 
    $email_message .= "" . clean_string($propery_Location) . "\n"; 
    $email_message .= "--------------------------------------------" . "\n"; 
    $email_message .= "Province: " . clean_string($drop_1) . "\n"; 
    $email_message .= "District: " . clean_string($drop_2) . "\n"; 
    $email_message .= "PD(Nahya): " . clean_string($drop_3) . "\n"; 
    $email_message .= "Bathrooms: " . clean_string($region) . "\n"; 
    $email_message .= "Street: " . clean_string($street) . "\n\n"; 
    $email_message .= "" . clean_string($contact_Information) . "\n"; 
    $email_message .= "--------------------------------------------" . "\n"; 
    $email_message .= "Name: " . clean_string($name) . "\n"; 
    $email_message .= "Email ID: " . clean_string($emailadd) . "\n"; 
    $email_message .= "Con-Email ID: " . clean_string($conemailadd) . "\n"; 
    $email_message .= "Phone(1): " . clean_string($phone1) . "\n"; 
    $email_message .= "Phone(2): " . clean_string($phone2) . "\n"; 
    // create email headers 
    $headers = 'From: ' . $emailadd . "\r\n" . 'Reply-To: ' . $emailadd . "\r\n" . 'X-Mailer: PHP/' . phpversion(); 
    @mail($email_to, $email_subject, $email_message, $headers); 
    @mail($emailadd, $email_subject_to_user, $email_message, "From: $email_to"); 
?> 



<!-- include your own success html here --> 



Your Property has been Posted please check your email address. 



<?php 
} 
?> 

回答