有人可以幫我解決我的郵件功能問題。郵件功能不正常
我想要在表格和附件中接收文本值。現在我正在接收表格代碼而不是代碼輸出和附件。
而如果我刪除我爲附件所做的修改,然後我得到正確的輸出,但只有文本。
<?php
include("config.php");
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$fn1 = $_POST['fn1'];
$fn2 = $_POST['fn2'];
$fn3 = $_POST['fn3'];
$fn4 = $_POST['fn4'];
$fn28= $_POST['fn28'];
$subject = 'test';
//get file details we need
$file_tmp_name = $_FILES['fn28']['tmp_name'];
$file_name = $_FILES['fn28']['name'];
$file_size = $_FILES['fn28']['size'];
$file_type = $_FILES['fn28']['type'];
$file_error = $_FILES['fn28']['error'];
$handle = fopen($file_tmp_name, "r");
$content = fread($handle, $file_size);
fclose($handle);
$encoded_content = chunk_split(base64_encode($content));
$boundary = md5("vikas");
//header
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From:".$email."\r\n";
$headers .= "Reply-To: ".$email."" . "\r\n";
$headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n";
$msg = "
<table border='1'>
<tbody>
<th>
<td><h3>Contact Information</h3></td>
</th>
<tr>
<td><b>Borrower's Full Name</b></td>
<td><span style='color:#F34536;'> $firstname $lastname </span></td>
</tr>
<tr>
<td><b>Email</b></td>
<td><span style='color:#F34536;'> $email</span></td>
</tr>
<tr>
<td><b>Attach Key Documents (optional)</b></td>
<td><span style='color:#F34536;'> $fn28</span></td>
</tr>
</tbody>
</table>
";
$msg1 = chunk_split(base64_encode($msg));
//plain text
$body = "--$boundary\r\n";
$body .= "Content-Type: text/plain; charset=ISO-8859-1\r\n";
$body .= "Content-Transfer-Encoding: base64\r\n\r\n";
$body .= $msg1;
//attachment
$body .= "--$boundary\r\n";
$body .="Content-Type: $file_type; name=\"$file_name\"\r\n";
$body .="Content-Disposition: attachment; filename=\"$file_name\"\r\n";
$body .="Content-Transfer-Encoding: base64\r\n";
$body .="X-Attachment-Id: ".rand(1000,99999)."\r\n\r\n";
$body .= $encoded_content;
mail($toemail, $subject, $body, $headers)
?>
能有人幫我一個郵件功能。我想在表格和附件中顯示文本字段? – Asif