Page 1 of 1

Mails to customers depending on categories

Posted: Fri Oct 21, 2016 12:49 pm
by jfvarin
Hi,

I spent time parsing the forum, and Google as well, to find a way to solve my problem, but I didn't find any answer.

I would like to send different type of mails depending on categories, with different templates : one template for support, another for contact...

I was considering to install several instances of Hesk (one per categoy), linked to the same database, but it doesn't seem to be the right way.

I thought there should be a variable which points to the mail folder I could modify depending on the category to point to another mail folder related to the category...

So, is there a simple way to do it or am I completely in a wrong way.

If someone has an idea, I will appreciate.
Thanks for help.

Greetings from Paris (France)

Jean-François

Re: Mails to customers depending on categories

Posted: Fri Oct 21, 2016 2:27 pm
by Klemen
Probably the fastest and easiest way would be to simply modify the function that retrieves email message.

For example:

1. create multiple copies of the "emails" folder (each with all the templates): emails, email_sales, emails_support, ...

2. in file inc/email_functions.inc.php replace this line:

Code: Select all

$eml_file = 'language/' . $hesk_settings['languages'][$hesk_settings['language']]['folder'] . '/emails/' . $eml_file . '.txt';
With something like:

Code: Select all

    switch ($ticket['category'])
    {
        case 1:
            $folder = 'emails_support';
            break;
        case 2:
            $folder = 'emails_sales';
            break;

        // More cases here...

        default:
            $folder = 'emails';
    }

    $eml_file = 'language/' . $hesk_settings['languages'][$hesk_settings['language']]['folder'] . '/'.$folder.'/' . $eml_file . '.txt';
So if the ticket was from category with ID 1, emails would be taken from folder "language/en/emails_support", if ticket was from ID 2 they would be from "language/en/emails_sales", ... and by default from the original "emails" folder.

It may not be the most convenient one, but it's a quick hack that doesn't require much coding.

Re: Mails to customers depending on categories

Posted: Sun Oct 23, 2016 3:59 am
by jfvarin
Hello Klemen,

Thanks for your answer which looks better than mine (far much easy to understand).

It is very close of what I did.
I wanted to stay category independant, so I choose to use an index instead of putting the folder name in the code, using "emails"."n" folder instead.

Code: Select all

   
$tempdir='/emails'.strval($ticket['category']);
 
$eml_file = 'language/' . $hesk_settings['languages'][$hesk_settings['language']]['folder'] . $tempdir.'/' . $eml_file . '.txt';
It was quick and dirty (probably much more dirty than quick)

As I don't know how many categories I have to manage, my next step will be to pick-up the information from the database and handle the folder names. I'm not sure it will be usefull but anyway I will try.

It will probably help to avoid the error message I'm facing when running hesk_pop3.php
"another Pop3 fetching..." ,"Une autre tâche de remplissage POP3 est en cours."

Jean-François