Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Delete files after email sent

Questions related to using nuBuilder Forte.
Post Reply
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 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: 4294
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 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