I have this form to send an email and the visitor can send an attachment with his email as will everything gos well the email sent but the attachment comes to the email like this
if he uploaded any C.V the C.V will be attached to this Email --_1_c4fe3315ccb7d6076c71d64ec5265ecc Content-Type: multipart/alternative; boundary="_2_c4fe3315ccb7d6076c71d64ec5265ecc"
--_2_c4fe3315ccb7d6076c71d64ec5265ecc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit
--_2_c4fe3315ccb7d6076c71d64ec5265ecc-- --_1_c4fe3315ccb7d6076c71d64ec5265ecc Content-Type: application/octet-stream; name="Yousef.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment
--_1_c4fe3315ccb7d6076c71d64ec5265ecc--
this is my php code to send my email
<?php
error_reporting(E_ALL | E_STRICT);
if (isset($_POST['submit'])) {
$sector = $_POST['cSector'];
$cAdministration = $_POST['cAdministration'];
$cBranch = $_POST['cBranch'];
$cCareer = $_POST['cCareer'];
$name = $_POST['cName'];
$telephone = $_POST['cTelephone'];
$cEmail = $_POST['cEmail'];
$cMessage = $_POST['cMessage'];
$recipient = 'info@test.com';
$subject = "Someone apply for career";
$myCv = $_FILES['upFile']['name'];
$attachment = chunk_split(base64_encode(file_get_contents($_FILES['upFile']['tmp_name'])));
$boundary = md5(date('r', time()));
$content = "This information is for someone who apply for your new career\n
Sector Applied For:" . $sector . ",\n
Administration Applied For:" . $cAdministration . ",\n
Branch Applied For:" . $cBranch . ",\n
Career Applied For:" . $cCareer . ",\n
His Name Is: " . $name . ",\n
His Phone Number: " . $telephone . ",\n
His Message: " . $cMessage . ",\n
His Email: " . $cEmail . ",\n if he uploaded any C.V the C.V will be attached to this Email
--_1_$boundary
Content-Type: multipart/alternative; boundary=\"_2_$boundary\"
--_2_$boundary
Content-Type: text/plain; charset=\"UTF-8\"
Content-Transfer-Encoding: 7bit
--_2_$boundary--
--_1_$boundary
Content-Type: application/octet-stream; name=\"$myCv\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment
$attachment
--_1_$boundary--";
$headers = "From:info@test.com\r\nReply-To:info@test.com";
$headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\"";
$sent = mail($recipient, $subject, $content, $headers);
if ($sent) {
header("Location:index.php?pid=17&carr=your message has been sent, we will contact you soon.");
} else {
echo "Error";
}
}
?>
Now I understood the problem, but still can not solve it completely.
the problem was in the space putting extra space for content-type
declaration code in His mail:
now when I remove the extra space the attach go right but the email body never come it come like the email just has an attach only
can anybody help me with that
thanks