Email piping not allowing multiple emails or CC

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
dllong
Posts: 6
Joined: Tue Jan 15, 2013 3:17 pm

Email piping not allowing multiple emails or CC

Post by dllong »

Script URL: lan
Version of script: 2.4.2
Hosting company: lan
URL of phpinfo.php: na
URL of session_test.php: na
What terms did you try when SEARCHING for a solution: multiple address, cc, carbon copy

Write your message below:
Sorry for yet another question, but this one might actually be the last one. I am using email piping and it is working great, however, when a customer sends an email to our ticketing system and they have multiple emails on the line and ones on CC, none of them are being added to the email.

The reason for this, is that numerous customers will send us support requests, and put other people in copy on the request.

Can you suggest how I could go about adding this functionality?

Thanks so much.
Klemen
Site Admin
Posts: 10139
Joined: Fri Feb 11, 2005 4:04 pm

Re: Email piping not allowing multiple emails or CC

Post by Klemen »

I'm afraid this would require several changes to the code and the way HESK behaves.

I plan to add such functionality to HESK (don't ask when :wink: ), but if you need in sooner than officially released I'm afraid you will need to hire a developer to help you out as customizations of such extent are out of the scope of my support.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
adrfazenda
Posts: 2
Joined: Thu Apr 11, 2013 12:54 pm

Re: Email piping not allowing multiple emails or CC

Post by adrfazenda »

Hi everyone!

I have made this customization to my Hesk and... well... it works. Actually, sometimes Hesk is opening a new ticket on replies. I'm still working on it and soon that I trace the problem I'll post here the solution.

To add this functionality the Hesk you have to edit file "/inc/pipe_functions.inc.php". Copy and paste the code between "STARTS HERE" and "ENDS HERE" to the function hesk_email2ticket.

Code: Select all

function hesk_email2ticket($results, $pop3 = 0)
{
	global $hesk_settings, $hesklang, $hesk_db_link, $ticket;

	// Process "From:" email
	$tmpvar['email'] = hesk_validateEmail($results['from'][0]['address'],'ERR',0);

	// "From:" email missing or invalid?
	if ( ! $tmpvar['email'] )
	{
		return NULL;
	}

	### CUSTOMIZATION STARTS HERE ###
	// Processa o campo "Cc:"
	foreach ($results['cc'] as $c => $cc)
	{
		// verifica se o campo é válido
		$tmpvar['cc'] = hesk_validateEmail($cc['address'],'ERR',0);

		// Se o campo "Cc" foi preenchido adiciona no campo de emails
		if ( $tmpvar['cc'] )
		{
			$tmpvar['email'] = $tmpvar['email'] . ',' . $tmpvar['cc'];
		}
	}
	### CUSTOMIZATION ENDS HERE ###

	// Process "From:" name, set to "[Customer]" if not set
	$tmpvar['name'] = hesk_input($results['from'][0]['name']) or $tmpvar['name'] = $hesklang['pde'];

	// Process "To:" email (not yet implemented, for future use)
	// $tmpvar['to_email']	= hesk_validateEmail($results['to'][0]['address'],'ERR',0);

I hope I've helped.

-- EDIT
I forgot to say this customization just works to the field CC. :roll:
---
Alessandro D. R. Fazenda
Klemen
Site Admin
Posts: 10139
Joined: Fri Feb 11, 2005 4:04 pm

Re: Email piping not allowing multiple emails or CC

Post by Klemen »

Thanks for sharing!
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
adrfazenda
Posts: 2
Joined: Thu Apr 11, 2013 12:54 pm

Re: Email piping not allowing multiple emails or CC

Post by adrfazenda »

Hi everyone!

I've made an improvement to the email parser.
My beloved users started to send tickets using the Hesk email address on CC: field and putting anyone else on TO: field. Result: some (important) people were missing to receive tickets solutions.
With this improvement users can use both CC: and TO: fields to open tickets and everybody will receive the solution.

It's the same file "/inc/pipe_functions.inc.php" and the same function hesk_email2ticket from my another post. Copy and paste the code between "STARTS HERE" and "ENDS HERE" and replace the other code.

Code: Select all

function hesk_email2ticket($results, $pop3 = 0)
{
	global $hesk_settings, $hesklang, $hesk_db_link, $ticket;

	// Process "From:" email
	$tmpvar['email'] = hesk_validateEmail($results['from'][0]['address'],'ERR',0);

	// "From:" email missing or invalid?
	if ( ! $tmpvar['email'] )
	{
		return NULL;
	}

	### CUSTOMIZATION STARTS HERE ###
	// Processa o campo "Cc:"
	foreach ($results['cc'] as $c => $cc)
	{
		// verifica se o campo é válido
		$tmpvar['cc'] = hesk_validateEmail($cc['address'],'ERR',0);

		// Se o campo "Cc" foi preenchido (e não é o proprio endereço do Hesk) adiciona no campo de emails
		if ( $tmpvar['cc'] && $tmpvar['cc'] != $hesk_settings['support_mail'] )
		{
			$tmpvar['email'] = $tmpvar['email'] . ',' . $tmpvar['cc'];
		}
	}

	// Processa o campo To:"
	foreach ($results['to'] as $t => $tt)
	{
		// verifica se o campo é válido
		$tmpvar['to_email'] = hesk_validateEmail($tt['address'],'ERR',0);

		// Se o campo "To" foi preenchido (e não é o proprio endereço do Hesk) adiciona no campo de emails
		if ( $tmpvar['to_email'] && $tmpvar['to_email'] != $hesk_settings['support_mail'] )
		{
			$tmpvar['email'] = $tmpvar['email'] . ',' . $tmpvar['to_email'];
		}
	}
	### CUSTOMIZATION ENDS HERE ###

	// Process "From:" name, set to "[Customer]" if not set
	$tmpvar['name'] = hesk_input($results['from'][0]['name']) or $tmpvar['name'] = $hesklang['pde'];

	// Process email subject, convert to UTF-8 if needed, set to "[Piped email]" if none set
	$tmpvar['subject'] = $results['subject'];
	if ( ! empty($results['subject_encoding']) && strtoupper($results['subject_encoding']) != 'UTF-8' )
	{
		$tmpvar['subject'] = iconv($results['subject_encoding'], 'UTF-8', $tmpvar['subject']);
	}
	$tmpvar['subject'] = hesk_input($tmpvar['subject'],'','',1) or $tmpvar['subject'] = $hesklang['pem'];
Cheers
---
Alessandro D. R. Fazenda
Klemen
Site Admin
Posts: 10139
Joined: Fri Feb 11, 2005 4:04 pm

Re: Email piping not allowing multiple emails or CC

Post by Klemen »

Thanks for sharing!
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Lisaweb
Posts: 94
Joined: Sun Sep 25, 2011 3:23 pm

Re: Email piping not allowing multiple emails or CC

Post by Lisaweb »

Yikes! I used your code and nearly crashed my server! Likely it's because it added the piping email address to the email field - and that created an infinite loop of email confirmations!

Does anyone know how to tweak the above code so it doesn't add the piping email address???

Thanks!
Lisa
- Lisa
Klemen
Site Admin
Posts: 10139
Joined: Fri Feb 11, 2005 4:04 pm

Re: Email piping not allowing multiple emails or CC

Post by Klemen »

Haven't used or tested any of the above code, but you will probably need something like

Code: Select all

(EMAIL VARIABLE) != 'your@pipedmail.com'
each place where an email could be added to the $tmpvar['email']
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
artec
Posts: 1
Joined: Fri Sep 16, 2022 3:43 pm

Re: Email piping not allowing multiple emails or CC

Post by artec »

Thx for sharing, I´ve found a solution, same file as descrived above (just replace xxx@support.com for your own support mail:

Code: Select all

// Processa o campo "Cc:"
	    foreach ($results['cc'] as $c => $cc)
	    {
		    // verifica se o campo é válido
		    $tmpvar['cc'] = hesk_validateEmail($cc['address'],'ERR',0);

		    // Se o campo "Cc" foi preenchido (e não é o proprio endereço do Hesk) adiciona no campo de emails
		    if ( $tmpvar['cc'] != 'xxx@support.com' )
		    {
			    $tmpvar['email'] = $tmpvar['email'] . ',' . $tmpvar['cc'];
		    }
	    }
	// Processa o campo To:"
	foreach ($results['to'] as $t => $tt)
	{
		// verifica se o campo é válido
		$tmpvar['to_email'] = hesk_validateEmail($tt['address'],'ERR',0);

		// Se o campo "To" foi preenchido (e não é o proprio endereço do Hesk) adiciona no campo de emails
		if ( $tmpvar['to_email'] != 'xxx@support.com' )
		{
			$tmpvar['email'] = $tmpvar['email'] . ',' . $tmpvar['to_email'];
		}
	}
To avoid the creation of new ticket when some of the CC reply, just delete the following code:

Code: Select all

// Do email addresses match?
	        if ( strpos( strtolower($ticket['email']), strtolower($tmpvar['email']) ) === false )
	        {
	        	$tmpvar['trackid'] = '';
	        }
cheers :mrgreen:
Klemen
Site Admin
Posts: 10139
Joined: Fri Feb 11, 2005 4:04 pm

Re: Email piping not allowing multiple emails or CC

Post by Klemen »

Cool, thank you!
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply