PHPMailer - 如何取消链接临时目录中的文件。?

时间:2014-06-08 10:07:37

标签: phpmailer email-attachments

我循环遍历文件数组,如中间的代码块所示,其余的代码只是为了更好的上下文。

$email = new PHPMailer();
$email->From      = 'John@example.com';
$email->FromName  = 'John Doe';
$email->Subject   = $name_talent;                        
$body = '<strong>ADDRESS</strong> : ' .$address_talent.'<br><br>';

if ($_FILES) {
    foreach ($_FILES as $file => $array) {
    $tmp_path = $_FILES[$file]['tmp_name'];
    $tmp_name = basename($_FILES[$file]['name']);
    $email->AddAttachment($tmp_path, $tmp_name);
    }
}

$email->Body = $body;
$email->IsHTML(true); 
$email->AddAddress( '#####@gmail.com' );
$email->Send();

这也会在$ body中发送带有值的附件。现在,我想在邮件发送或附件成功后取消链接文件。作为灵感from this answer,如果我在下面这样做,没有附加文件以及为$ body设置的任何变量,例如。 <{1}} 在电子邮件中不会出现

$address_talent

0 个答案:

没有答案