【发布时间】:2018-02-25 02:14:16
【问题描述】:
在弄清楚 PhpMailer 之后,我现在一直专注于如何将文件移出数据库并作为附件附加到电子邮件中。在 phpMailer 网站上,附件必须有 4 个细节才能附加,即: $mail->addAttachment($path, $name, $encoding, $type);我有 3 个,但从我的数据库下载知道我没有 $path。我想到了将我的文件从我的数据库移动到一个临时位置,然后作为附件上传的可能性,但是我在这方面找不到任何东西。我有能力从数据库中下载我的文件。我在下面包含了该代码。
这是我的 PHPMailer 文件中的代码:
m->isHTML(true);
//adding file to be attached
$m->addAttachment($path, $name, $encoding, $type);
$m->Subject = "Here is an Email";
$m->Body = "<p>This is the body of the email</p><br><strong>Test for
HTML formatting</strong><br>";
$m->AltBody = "This is the body of an email";
$m->send();
echo "message has been sent";
这是我的文件下载文件中的代码。
$filename = $rows['name'];
$filesize = $rows['filesize'];
$content = $rows['wholeMP3'];
$type = $rows['type'];
header("Content-length: $filesize");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$filename");
ob_clean();
flush();
echo $content;
$LastProduct->closeCursor();
【问题讨论】: