【发布时间】:2018-05-15 10:46:56
【问题描述】:
我正在使用 php mailer 发送带有附件的电子邮件。我希望将文件附加在同一页面中。我的表格,
<form method="POST" action="#" enctype="multipart/form-data">
<label>Files to upload:</label>
<input type="file" name="files[]" multiple/>
<button type="submit" name="btnSend" value="Send">Send</button>
</form>
而我的 php 代码 sn-p 是,
if (isset($_POST['btnSend'])) {
$mail = new mymailer();
include DOC_ROOT . 'include/contact-email-template.php';
$mailArray = array("my-email-address");
$subject = "Contact Form";
$from = $email;
$mail->sendMail($from, $mailArray, $subject, $admin_template);
$emailsent = 1;
$mod_email = "Success";
/* redirect to home after success */
if ($emailsent == 1) {
unset($_POST['firstname']);
unset($_POST['lastname']);
unset($_POST['email']);
unset($_POST['phone']);
unset($_POST['message']);
$mod_email = "Show";
}
}
如何附加我从@987654324@ 中选择的文件 请帮忙。
PS:即使我将操作设置为外部文件并将所选图像保存在磁盘中并附加它们,使用此代码发送的电子邮件也很好。 我只想知道如何在同一页面中附加文件。
【问题讨论】:
-
您必须先将这些文件上传到服务器,然后将其附加到邮件中
-
查看PHPMailer提供的'send file upload' example。
标签: php email phpmailer attachment email-attachments