Seen a number of people ask for this in the request community:
Many of the large ticketing systems (Zendesk, SupportPal, FreshDesk, etc.) allow the ability for an administrator/ticket operator to forward an email they receive in their personal mailbox to the ticketing system, and it will open the ticket "On Behalf" of the user who emailed them. I would like to see this ability in WHMCS for both existing and new customers who may email a staff member directly, instead of using the ticketing system.
I have created a hook which allows this to work. I have tested on the most recent version of WHMCS and all seems okay.
<?
add_hook("TicketPiping",1,"fwd_ticket_pipe");
if(!function_exists("fwd_ticket_pipe"))
{
function fwd_ticket_pipe($vars)
{
$to = $vars['to'];
$subject = $vars['subject'];
if (strpos($subject, 'Fwd:') !== false) {
$adminonly = false; // For admin only import
$subject = str_replace("Fwd: ", "", $vars['subject']);
$lines = explode("\n", $vars['body']);
$message = '';
for ($i=0; $i < count($lines); $i++) {
$lines[$i] = str_replace("> ","",$lines[$i]);
//Split out the sender information portion
if (preg_match("/From: (.*)<(.*)>/", $lines[$i], $matches)) {
$name = $matches[1];
$email = $matches[2];
} else {
}
if($i > 8)
{
$message .= $lines[$i].'
';
}
}
if($adminonly)
{
$adminrow = Illuminate\Database\Capsule\Manager::table("tbladmins")->where("email","=",$vars['email'])->count();
if($adminrow > 0)
{
logActivity('Forwarded email is sent from an admin email account. It has been imported', 0);
processPipedTicket($to, $name, $email, $subject, $message, $vars['attachments']);
} else {
logActivity('Forwarded email is not sent from an admin email account. It has NOT been imported', 0);
}
} else {
logActivity('Forwarded email is sent from a generic email account. It has been imported', 0);
processPipedTicket($to, $name, $email, $subject, $message, $vars['attachments']);
}
exit();
}
}
}