邮件功能不正常
问题描述:
有人可以帮我解决我的邮件功能问题。邮件功能不正常
我想要在表格和附件中接收文本值。现在我正在接收表格代码而不是代码输出和附件。
而如果我删除我为附件所做的修改,然后我得到正确的输出,但只有文本。
<?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)
?>
答
是因为你有这样一行:
$body .= "Content-Type: text/plain; charset=ISO-8859-1\r\n";
所有的代码是在text-plain
发送,删除它,修改它,因为text/html
在$header
:
$header .= 'MIME-Version: 1.0\r\n';
$header .= 'Content-type: text/html; charset=iso-8859-1\r\n';
+0
不客气:)请投票正确答案。 –
+0
我没有投票。 https://www.dropbox.com/s/dlfc11dgq9td9oz/Screenshot%202015-10-16%2008.04.34.png?dl=0 – Asif
能有人帮我一个邮件功能。我想在表格和附件中显示文本字段? – Asif