cjsmith87 Posted May 13, 2019 Share Posted May 13, 2019 Because of the way WHMCS sends all Ticket Emails to main Client even if logged by a Contact, we disable the standard emails and send our own using hooks and PHPMailer so that we can only send them to the contact if one is defined. Is there a better way to achieve this? It seems a bit hacky! add_hook('TicketClose', 1, function($vars) { Tools::sendTicketEmail($vars,'closed'); }); function sendTicketEmail($vars, $type) { // Get the required data $headertt = file_get_contents('<Removed>/headerCustom.tpl'); $footertt = file_get_contents('<Removed>/footerCustom.tpl'); $ticket_details = Capsule::table('tbltickets')->where('id', $vars['ticketid'])->first(); $department_details = Capsule::table('tblticketdepartments')->where('id', $ticket_details->did)->first(); $emailsURL = '<Removed>/viewticket.php?tid=' . $ticket_details->tid .'&c=' . $ticket_details->c; $headertt = str_replace('{$emailsURL}', $emailsURL , $headertt); // Create a new PHPMailer object $mail = new PHPMailer(TRUE); // Set TRUE to enable exceptions $mail->IsSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.office365.com'; // Specify main and backup server $mail->Port = 587; // Set the SMTP port ... The second problem i am having with this is when i am calling it from my modules Hooks.php, My SendTicketEmail function wont work unless it is in the hooks.php file. I have tried adding it to my tools class, which has other methods in it that call fine, but it cant seem to find the PHPMailer class? I have tried lots of requires... statements but cant seem to get it right. What do i need to do to get a custom class access the standard WHMCS classes that seem to be available to Hooks.php? 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.