我正通过一个.swf文档将表格数据发送到该PHP网页。 发出电子邮件时,如果附有附件,则电文的正体不会出现,但如果没有附件,则该机关似乎只是罚款。 我知道,所有变量名称都是正确的,因为所有数据都是从 s手中提取的。 我是否以某种方式设立了电子邮件,使电子邮件能够发挥作用? 让我知道。
<?php
$to=$_POST[ toEmail ];
$subject=$_POST[ subject ];
$body = $_POST[ messaggio ];
$nome = $_POST[ nome ];
$email = $_POST[ email ];
$attach = $_POST[ attach ];
$headers = "From: $nome<" . $email . ">
";
if ($attach == 1) {
$tmp_name = $_FILES[ Filedata ][ tmp_name ];
$type = $_FILES[ Filedata ][ type ];
$name = $_FILES[ Filedata ][ name ];
if(is_uploaded_file($tmp_name)){
$file = fopen($tmp_name, rb );
$data = fread($file,filesize($tmp_name));
fclose($file);
$data = chunk_split(base64_encode($data));
$headers .= "Reply-To: <" . $email . ">
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: multipart/related; type="multipart/alternative"; boundary="----=MIME_BOUNDARY_main_message"
";
$headers .= "X-Sender: $to <" . $to . ">
";
$headers .= "Return-Path: <" . $email . ">
";
$headers .= "This is a multi-part message in MIME format.
";
$headers .= "------=MIME_BOUNDARY_main_message
";
$headers .= "Content-Type: multipart/alternative; boundary="----=MIME_BOUNDARY_message_parts"
";
$message = "------=MIME_BOUNDARY_message_parts
";
$message .= "Content-Type: text/plain; charset="iso-8859-1"
";
$message .= "Content-Transfer-Encoding: quoted-printable
";
$message .= "
";
$message .= $body . "
";
$message .= "
";
$message .= "------=MIME_BOUNDARY_message_parts--
";
$message .= "
";
$message .= "------=MIME_BOUNDARY_main_message
";
$message .= "Content-Type: application/octet-stream;
name="" . $name . ""
";
$message .= "Content-Transfer-Encoding: base64
";
$message .= "Content-Disposition: attachment;
filename="" . $name . ""
";
$message .= $data;
$message .= "
";
$message .= "------=MIME_BOUNDARY_main_message--
";
mail($to, $subject, $message, $headers);
}
} else {
if(mail($to, $subject, $body, $headers)) {
echo "ok=1";
}
}
?>