ST4R Posted February 19 Share Posted February 19 Hello friends, I have written a hook for WHMCS that saves each email sent to users as a file. However, this hook is not working, and the $vars array is empty and contains no values. Please guide me. <?php use WHMCS\User\Client; function emailSentHook($vars) { $directory = $_SERVER['DOCUMENT_ROOT'] . '/something/'; $email = $vars['to']; $content = $vars['message']; file_put_contents($email, $content); } add_hook('EmailPreSend', 1, 'emailSentHook'); 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted February 20 Share Posted February 20 The $vars array does not contain the keys you are using. You have the following available: - $vars['messagename'] - $vars['relid'] - $vars['mergefields'] https://developers.whmcs.com/hooks-reference/everything-else/#EmailPreSend The EmailPreLog even contains the keys you are trying to access: https://developers.whmcs.com/hooks-reference/everything-else/#EmailPreLog 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.