您好,我正在用pdd/doc附件發送一封電子郵件。當我點擊發送電子郵件時,我收到一封正確附件的電子郵件,但我沒有收到郵件正文部分的郵件內容。當我點擊查看節目原創時,我可以在原始內容中看到該內容,但在電子郵件中看不到。 這是我的代碼。任何人都可以幫助我知道如何讓他們在正確的地方?使用附件發送電子郵件時身體部位丟失
<?PHP
session_start();
$applicant_name = (isset($_POST["applicant_name"])) ? $_POST["applicant_name"] : '';
$applicant_age = (isset($_POST["age"])) ? $_POST["age"] : '';
$applicant_gender = (isset($_POST["gender"])) ? $_POST["gender"] : '';
$preferred_email = (isset($_POST["preferred_email"])) ? $_POST["preferred_email"] : '';
$MobileNo = (isset($_POST["preferred_mobile_no"])) ? $_POST["preferred_mobile_no"] : '';
$_SESSION['jobTitle'];
$_SESSION['jobId'];
$pdf_doc='';
if(isset($_FILES['document_url']['name'])){
$pdf_doc = rand() . "_" . $_FILES['document_url']['name'];
copy($_FILES['document_url']['tmp_name'], "job_docs/" . $pdf_doc);
}
$name = $applicant_name;
$email = "[email protected]";
$to = "Karda <".$email.">";
$from = $preferred_email;
$subject = "Application for post : ".$_SESSION['jobTitle']."[".$_SESSION['post_id']."]";
$mainMessage = "<br/>Applicant Name :- " . $applicant_name . "\n\n"
. "<br/>Email:- " . $preferred_email . "\n\n"
. "<br/>Phone:- " . $MobileNo . "\n\n"
. "<br/>Age:- " . $applicant_age . "\n\n"
. "<br/>Gender:- " . $applicant_gender . "\n\n";
$fileatt = "job_docs/".$pdf_doc;
$fileatttype = "application/pdf";
$fileattname = "job_docs/".$pdf_doc;
$headers = "From: $preferred_email";
// File
$file = fopen($fileatt, 'rb');
$data = fread($file, filesize($fileatt));
fclose($file);
// This attaches the file
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" ."Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
$message = $mainMessage."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\n";
$data = chunk_split(base64_encode($data));
$message .= "--{$mime_boundary}\n" ."Content-Type: {$fileatttype};\n" ." name=\"{$fileattname}\"\n" ."Content-Disposition: attachment;\n" ." filename=\"{$fileattname}\"\n" ."Content-Transfer-Encoding: base64\n\n" .$data . "\n\n" ."-{$mime_boundary}-\n";
// Send the email
if(mail($to, $subject, $message, $headers)) {
header("location:we_are_hiring.php");
}
else {
header("location:index.php");;
}
?>
如果相關不知道,但你在這裏有一個額外的分號:'頭( 「地點:的index.php」)?; ;' – Jonast92 2014-11-25 10:52:07
嘗試發送您的附件不在按摩頭。 – 2014-11-25 10:57:02