在php中发送带有多个附件的邮件

时间:2012-12-11 20:21:15

标签: php

我有此表单发送包含6个附件的电子邮件。我需要帮助来编写php处理脚本以发送多个附件。如果我能得到关于如何编写处理脚本以在php中发送带有多个附件的电子邮件的提示,我将很高兴。

<<html>
<head>
<title>Send an Email</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>Send an Email</h1>
<form action="mail.php" method="POST" enctype="multipart/form-data">
<p>&nbsp;</p>
<table width="579" border="0">
<tr>
<td wid th="61">Email From:</td>
<td colspan="3"><input name="emailfrom" type="text" value="" size="90" /></td>
</tr>
<tr>
<td>Emai  To: </td>
<td colspan="3"><label for="emailto"></label>
  <textarea name="emailto" id="emailto" cols="70" rows="3"></textarea></td>
 </tr>
<tr>
<td valign="middle">Subject::</td>
<td colspan="3"><input name="subject" type="text" value="" size="90" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td>Message:</td>
<td colspan="3"><textarea cols="70" rows="18" name="message"></textarea></td>
</tr>
<tr>
<td nowrap>Attach file</td>
<td width="224"><input name="file1" type="file" class="send" size="24" /></td>
<td width="61" nowrap>Attach file</td>
<td width="218"><input name="file2" type="file" size="24" /></td>
 </tr>
<tr>
<td nowrap>Attach file</td>
<td><input name="fil3" type="file" class="send" size="24" /></td>
<td nowrap>Attach file</td>
<td><input name="file4" type="file" size="24" /></td>
 </tr>
<tr>
<td nowrap>Attach file</td>
<td><input name="file5" type="file" class="send" size="24" /></td>
<td nowrap>Attach file</td>
<td><input name="file6" type="file" size="24" /></td>
</tr>
<tr>
<td nowrap>&nbsp;</td>
<td>&nbsp;</td>
<td nowrap>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td nowrap>&nbsp;</td>
<td>&nbsp;</td>
<td nowrap>&nbsp;</td>
<td align="right"><input type="submit" class="send" value="Send" /></td>
 </tr>
</table>

</form>

1 个答案:

答案 0 :(得分:0)

您可以使用<input type='file' name='file[]' multiple>上传多个文件。看看this教程。它应该有所帮助!

我会考虑使用PHPMailer。您将要使用$mail->AddAttachment($path);

轻松附加文件