Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

Delete files after email sent

Questions related to using nuBuilder Forte.
Post Reply
yvesf
Posts: 347
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 94 times
Been thanked: 12 times

Delete files after email sent

Unread post 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
kev1n
nuBuilder Team
Posts: 4562
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 528 times
Contact:

Re: Delete files after email sent

Unread post 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]);
Post Reply