<?php
$file = $_FILES["file"]["tmp_name"];
$file1 = $_FILES["file1"]["tmp_name"];
$attachment_path = $file;
$attachment_path1 = $file1;
$body = "some text";
include("class.phpmailer.php");
//Create a new PHPMailer instance
$mail = new PHPMailer();
//Set who the message is to be sent from
$mail->SetFrom('mail@example.com', $username);
//Set who the message is to be sent to
$mail->AddAddress('mail@example.com', 'Ticket Relief');
//Set the subject line
$mail->Subject = 'Inquiry from website by Form Fillup';
//Replace the plain text body with one created manually
$mail->Body = $body;
//Attach an image file
$mail->AddAttachment($attachment_path, "attachment1", "base64", "application/octet-stream");
$mail->AddAttachment($attachment_path1, "attachment1", "base64", "application/octet-stream");
//Send the message, check for errors
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Email has been sent! Please <a href='index.php'>Click Here </a> to go back to home page";
}
?>
和html代码
<form action="functions.php" method="post" enctype="multipart/form-data">
<div class="outer1">
<label> Please Choose File</label>
<input type="file" class="span4" name="file">
</div>
<div class="outer1">
<label> Please Choose File</label>
<input type="file" class="span4" name="file1">
</div>
<div class="outer1">
<input type="submit" class="submit btn btn-success btn-large pull-right" value="Submit">
</div>
</form>
- 我正在接收电子邮件,但无法打开附件。它的格式未知。
- 如果文件超过 200kb,则发送邮件需要 40-45 秒,如果文件超过 600kb,则需要超过 1 分钟来处理
在这些问题上需要帮助