Atomic Posted November 25, 2016 Share Posted November 25, 2016 I had a hook made years ago that sends an email to techs when a note is made. We just moved our installation to a new server and new domain. WHMCS version is the same (v6) and the only change was a move from PHP 5.2 to 5.6. This is the code, can anyone see any problems with it? <?php if (!defined("WHMCS")) die("This file cannot be accessed directly"); function emailonaddticketnote_SendEmail($fromemail,$toemail, $fromname, $toname, $subject, $message) { global $CONFIG; if($CONFIG['LogoURL']) { $sendmessage = '<p><a href="'.$CONFIG['Domain'].'" target="_blank"><img src="'.$CONFIG['LogoURL'].'" alt="'.$CONFIG['CompanyName'].'" border="0"></a></p>'; } $sendmessage .= '<font style="font-family:Verdana;font-size:11px"><p>'.$message.'</p>'; $mail = new PHPMailer(); $mail->From = $fromemail; $mail->FromName = $fromname; $mail->Subject = $subject; $mail->CharSet = $CONFIG['Charset']; if($CONFIG['MailType'] == "mail") { $mail->Mailer = "mail"; } elseif($CONFIG['MailType'] == "smtp") { $mail->IsSMTP(); $mail->Host = $CONFIG['SMTPHost']; $mail->Port = $CONFIG['SMTPPort']; $mail->Hostname = $_SERVER['SERVER_NAME']; if($CONFIG['SMTPSSL']) { $mail->SMTPSecure = $CONFIG['SMTPSSL']; } if($CONFIG['SMTPUsername']) { $mail->SMTPAuth = true; $mail->Username = $CONFIG['SMTPUsername']; $mail->Password = decrypt($CONFIG['SMTPPassword']); } $mail->Sender = $CONFIG['Email']; $mail->AddReplyTo($fromemail, $fromname); } $mail->AddAddress($toemail, $toname); $message_text = str_replace("</p>", "\r\n\r\n", $sendmessage); $message_text = str_replace("<br>", "\r\n", $message_text); $message_text = str_replace("<br />", "\r\n", $message_text); $message_text = strip_tags($message_text); $mail->Body = $sendmessage; $mail->AltBody = $message_text; $mail->Send(); $mail->ClearAddresses(); return true; } function emailonaddticketnote($vars) { global $CONFIG; $companyname = $CONFIG['CompanyName']; $whmcsurl = $CONFIG['SystemURL']; $readmins = mysql_query("SELECT `firstname`,`lastname` FROM `tbladmins` WHERE `id`='".$vars['adminid']."'"); $data = mysql_fetch_array($readmins); $query = mysql_query("SELECT `id` FROM `tbladminroles` WHERE `supportemails`='1'"); while ($row = mysql_fetch_assoc($query)) { $queryb = mysql_query("SELECT `email`,`firstname`,`lastname` FROM `tbladmins` WHERE `roleid`='".$row['id']."'"); while ($result = mysql_fetch_assoc($queryb)) { $ticketurl = $whmcsurl."/admin/supporttickets.php?action=view&id=".$vars['ticketid']; $message = "Hello ".$result['firstname'].",<br /><br />A note has been added to ticket #".$vars['ticketid']."<br /><br />Note: ".$vars['message']."<br />By admin: ".ucwords($data['firstname']." ".$data['lastname']."<br /><br />To view the ticket please click here:<br/><a href='".$ticketurl."'>".$ticketurl."</a><br /><br />Thank You,<br>".$companyname); $fullname = $result['firstname'].' '.$result['lastname']; $email = $result['email']; emailonaddticketnote_SendEmail($email,$email, $companyname, $fullname, 'Note added to ticket #'.$vars['ticketid'], $message); } } } add_hook("TicketAddNote",1,"emailonaddticketnote"); Cheers. It's a useful hook, feel free to use it and make a note and see if it works. If it does then there is a misconfig in our system due to the changeover. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 25, 2016 Share Posted November 25, 2016 if it helps, i've just tried this hook on a v7.1beta dev installation using PHP 5.6 and it works fine... so I don't think PHP 5.6 is the issue... I would guess a mail setting error somewhere. 0 Quote Link to comment Share on other sites More sharing options...
Atomic Posted November 25, 2016 Author Share Posted November 25, 2016 Hey Brian, one of my techs just fixed this. Under Settings > Mail we had no SSL and "localhost" set. We had to put the server hostname, SSL port and enable SSL. This system was running on cPanel before and now it's Plesk so perhaps there is some internal way that cPanel handles encrypted mail that differs to Plesk. Can't be bothered to dig into now but it works. Thanks for looking though! 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.