Page 1 of 1

Delete files after email sent

Posted: Thu Jan 05, 2023 2:07 pm
by yvesf
Hello,

I would like to delete files in attachments once the email sent.
Here is my php code

Code: Select all

$file = "#filename#";           // get Filename
$filename = basename($file);  // file name only
$to_email ="#fac_client_email#";

if(file_exists($file)){
    nuSendEmail($to_email,'$from_email','username','object','content',[$filename => $file],true); 
nuDeleteFiles($file);
 // Send E-Mail
}else{
    nuDebug('Cannot send ' . $file);
}
It seems that nuDeleteFiles() is not working. It isn't documented and therefore I don't know how to use it. I haven't found any function function nuDeleteFiles in the code.
Any idea ?
Many thanks,

Yves

Re: Delete files after email sent

Posted: Thu Jan 05, 2023 2:55 pm
by kev1n
Untested, $file has to be passed as an array when looking at the source code:

Code: Select all

function nuDeleteFiles($file_list = array()) 
Like this:

Code: Select all

nuDeleteFiles([$file]);