Jump to content

cuenta0gow

New Member
  • Posts

    3
  • Joined

  • Last visited

Everything posted by cuenta0gow

  1. Version: WHCMS 8.12.0 Type of license: Plus The files we attach in our tickets won't send, despite of being uploaded. We press the "Attach Files" button, choose any file then we send. The mail is received without the attachment. We already checked all users permissions to determine that is not the problem. We are aware there are some allowed file extensions and the max file size limit, we respect those and attachments still not sending. We gave all permissions to "attachments" and "downloads" directories in WHMCS document root to prove is not a permissions issue, but it didn't work. There is nothing in system logs that tells us if there is something wrong. We already checked every setting in Configuration and everything looks enabled. When clients send us emails files are attached correctly . Do you know what is causing our issue? Any help would be appreciated, thanks in advance! If you need us to provide anything information, just let us know please.
  2. I'm configuring a WHMCS "TicketOpen" hook to send a notification to our Synology Chat using a webhook. It actually works, the issue here is that we would like to include in the notification sender's mail account or who opened the ticket. We would rather just the mail account because we have several clients who send us tickets from unregistered email accounts. Our notifications look like this when they are received: New ticket created by: (we get nothing here, expected output:) [ mailaccount@domain.com ] or [ CLIENT_NAME CLIENT_SURNAME] Ticket ID: (example) IHC-261848 Subject: (example) Support request! New ticket created by: Unknown sender (expected output:) [ account@domain.com ] or [ CLIENT_NAME CLIENT_SURNAME] Ticket ID: (example) IHC-261848 Subject: (example) Support request! Mail Account: Unknown We are using the official reference hook guide and the available parameters (ticketid, ticketmask, userid, deptid, deptname, subject, message, priority) don't include any to retrieve sender's mail account so we are posting this to see if you can give us any advice on how to do this. Here is the hook script we have so far: <?php add_hook('TicketOpen', 1, function($vars) { // Debug log $logFile = '/tmp/whmcs_ticket_debug.log'; // Save $vars structure in the log file to verify what data is being received file_put_contents($logFile, "Received data: " . print_r($vars, true), FILE_APPEND); // Get ticket ID $ticketMask = $vars['ticketmask'] ?? 'No ID'; file_put_contents($logFile, "Ticket Mask: $ticketMask\n", FILE_APPEND); // Default client's name is 'Unknown' $clientName = 'Unknown sender'; $clientEmail = 'Unknown'; // Additional variable for email // If the ticket is sent by a registered user (userid isn't empty) if (!empty($vars['userid'])) { // Get client details $clientDetails = localAPI('GetClientsDetails', ['clientid' => $vars['userid']]); // If it finds a name or a mail account it uses it $clientName = $clientDetails['fullname'] ?? 'Unknown client'; $clientEmail = $clientDetails['email'] ?? 'Unknown'; file_put_contents($logFile, "Registered client: $clientName, Mail account: $clientEmail\n", FILE_APPEND); } else { // If there is no userid, try to retrieve it from the mail itself if (!empty($vars['message'])) { if (preg_match('/[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}/', $vars['message'], $matches)) { $clientEmail = $matches[0]; $clientName = 'Sender: ' . $clientEmail; file_put_contents($logFile, "Unregistered client, mail account found: $clientEmail\n", FILE_APPEND); } else { file_put_contents($logFile, "It wasn't possible to find a mail account in the message.\n", FILE_APPEND); } } } // Get ticket's subject $subject = $vars['subject'] ?? 'Unknown subject'; file_put_contents($logFile, "Subject: $subject\n", FILE_APPEND); // Write the notification message for Synology Chat $message = "New ticket created by: $clientName\nTicket ID: $ticketMask\nSubject: $subject\nMail Account: $clientEmail"; file_put_contents($logFile, "Notification preview: " . $message . "\n", FILE_APPEND); // Synology Chat webhook URL $url = 'https://CENSORED FOR OBVIOUS REASONS...'; // Create payload $payload = ['payload' => json_encode(['text' => $message])]; // Start up curl $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload)); // Run curl request $response = curl_exec($ch); // Log curl response file_put_contents($logFile, "Curl output: $response\n", FILE_APPEND); // Close curl session curl_close($ch); }); ?> And this is the last logged response from the debug log we added: Received data: Array ( [ticketid] => 81 [ticketmask] => STW-189085 [userid] => [deptid] => 2 [deptname] => Technical Support [subject] => 04/04 10:45 second test [message] => This is a test. [priority] => Medium ) Ticket Mask: STW-189085 It wasn't possible to find a mail account in the message Subject: 04/04 10:45 second test Notification preview: New ticket created by: Unknown sender Ticket ID: STW-189085 Subject: 04/04 10:45 second test Mail Account: Unknown
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated