HESK e-mail piping public BETA (test version)

Helpdesk for my helpdesk software

Moderator: mkoch227

egidux77
Posts: 4
Joined: Fri Feb 25, 2011 2:26 pm

Re: HESK e-mail piping public BETA (test version)

Post by egidux77 »

Klemen wrote:@egidux77

You will probably need to change the charset in your language text.php file to a charset that support the special chars, probably to ISO-8859-2 or UTF-8

You can also send a sample e-mail to pipe {at} hesk (dot) com which will log the contents of the e-mail for me to see and check.
I changed encoding in text.php file to UTF-8. But that not helps. After that i changed my email client to force set encoding to UTF-8 to all outgoing emails. Now everything looks ok. But I think there is a partial solution, because in real world not all incoming emails will be in UTF-8. I think some kind of converter is needed?

Another issue is with notification mails - links to submited ticket is not active in email. Configuration issues or something else?
mcekl
Posts: 1
Joined: Sun Mar 06, 2011 10:12 am

Re: HESK e-mail piping public BETA (test version)

Post by mcekl »

I love HESK.. it's easy to set up and does the job well. The addition of email piping is excellent as i have to run a small support desk that has used emails up until now, so i was hoping to be able to channel all their emails into tickets.
However, being a very small setup with limited funds, we can only afford a shared hosting ISP for our web & email servers, so when I tried to setup the email forwarding it does not allow me to forward to a program... only email addresses. The ISP tells me the only solution is to have a dedicated server but we cant afford that monthly cost, so...
is there a way of using existing mail functions available within a shared host PleskCP to force the emails towards the email piping ? The existing shared server handles outgoing my existing other php scripts sending SMTP emails via port 25 OK
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Re: HESK e-mail piping public BETA (test version)

Post by Klemen »

You don't need a dedicated server to setup email piping, the hosting staff either aren't very knowledgeable or (more likely) are trying to sell you services you don't need.

CPanel has a very easy method of setting up piping, but your hosting company uses Plesk as their control panel that, to the best of my knowledge, doesn't support piping setup. However, it would only take a minute of work for a server admin to set this up for you:

They will need to modify the /var/qmail/mailnames/yourDomain/yourPipingAddress/.qmail file. It looks something like this:

Code: Select all

| true
./Maildir/
It just needs an extra line:

Code: Select all

|true
|/path/to/hesk/inc/mail/hesk_pipe.php
./Maildir/
Then they need to restart the qmail service, probably using:
service qmail restart

It's a minute of work at most. If they don't want to do this for you, consider switching to a host that does.

P.s.: I plan to modify the script to also be able to read emails from mailboxes directly without the need for piping directly to the script.
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
Enc
Posts: 3
Joined: Tue Mar 15, 2011 11:15 am

Re: HESK e-mail piping public BETA (test version)

Post by Enc »

Hi Klemen,

thanks for this great addition to Hesk!

I also have no direct access to something like CPanel´s "Pipe to program:" feature, since I´m using KAS on a shared hosting webspace.

However, I just called support and they told me there is a way to accomplish piping. The support guy wasn´t really good at explaining though... (or maybe I´m just too stupid).

Maybe you can help out?

First, I created a mailbox called help@mydomain.com

After doing this I can now log into the newly created mailbox account via FTP and I get this folder structure:
Image
The File "user_procmailrc" is empty.
The file ".procmailrc" contains the following code:

Code: Select all

SHELL=/bin/sh
# to switch on logging:
#LOGFILE=.procmail.log
#VERBOSE=1
# procmail-file which can be edited by user
INCLUDERC=user_procmailrc
# procmail-file from KAS
INCLUDERC=kas_procmailrc
I can also log into my mail-account via webmail interface. There I have a menu item called "Procmail-Editor" where I can enter something (probably rules?) into a big white text field.

Now what the support guy told me ist to upload the script(?) via FTP and then create a rule like "/home/popuser/mailbox_name/script_name" in the Procmail-Editor via the webmail-inteface.

Any ideas on that?
Any help is appreciated! :-)

Best wishes from Hamburg,
Enc
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Re: HESK e-mail piping public BETA (test version)

Post by Klemen »

I'm afraid I'm not familiar with KAS/procmail so I can't be of much help. You will need to check with your host (again).
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
Enc
Posts: 3
Joined: Tue Mar 15, 2011 11:15 am

Re: HESK e-mail piping public BETA (test version)

Post by Enc »

Well, thanks anyway! :D

My provider told me he won´t go through the process with me since it´s not part of their service. Will you - in addition to piping (aliases) - also support POP3/IMAP polling method in the future? Hesk is exactly what I need but e-mail tickets are essential for our workgroup... nobody´s gonna use the web interface... :?
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Re: HESK e-mail piping public BETA (test version)

Post by Klemen »

Probably yes, Hesk will support POP/IMAP fetch, but not sure if already in version 2.3
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
Enc
Posts: 3
Joined: Tue Mar 15, 2011 11:15 am

Re: HESK e-mail piping public BETA (test version)

Post by Enc »

Thanks for the info!
And keep up the good work! :)
jeanguy
Posts: 1
Joined: Wed Mar 23, 2011 11:39 am

Re: HESK e-mail piping public BETA (test version)

Post by jeanguy »

What would be great is a POP3/IMAP php program to pipe the emails in HDesk
(because cPanel is not provided very often).

There are great php functions like imap_open, imap_headerinfo, imap_body ...

This imap program could be called automatically via a cron table.

What do you think about that ?
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Re: HESK e-mail piping public BETA (test version)

Post by Klemen »

Check my last reply :wink:
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
colin65
Posts: 2
Joined: Thu May 05, 2011 3:58 am

Re: HESK e-mail piping public BETA (test version)

Post by colin65 »

Thanks for the beta version of the email piping. I'm finding that it works brilliantly.

I have also made a slight modification to this code and the database to add the following features:

1. Added new table hesk_category_email that contains a cross-reference between and category ID and an email address. Email address has a unique index (so one email can't belong to > 1 categories) but it IS possible to map multiple email addresses to the same category.

2. Modified the hesk_pipe.php file to read the TO address from the parsed results and then lookup the corresponding category ID from the hesk_category_email table. I then insert this ID (instead of the hard-coded default category) into the new ticket.

This works great and it means I can easily route emails from different addresses to the appropriate category. Anything that does not have a matching address goes into the default category.

I'm happy to send you the modified file although I'm sure you can implement that pretty easily (and I am not a PHP programmer so you would probably do it better).

Just wanted to share my idea in case anyone else wanted to do / achieve the same thing.

Ideally there would be a configuration page to map email addresses to categories via the GUI. Beyond my level of tinkering though, I'm afraid, so I just set mine manually be inserting entries in the table using phpmysql.
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Re: HESK e-mail piping public BETA (test version)

Post by Klemen »

Great idea, 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
christinaG
Posts: 1
Joined: Thu May 26, 2011 12:19 am

Re: HESK e-mail piping public BETA (test version)

Post by christinaG »

HESK is brilliant, and the piping is fabulous, I will vote with my wallet :) I love the previous posters idea of multiple email piping to categories, and am going to try that myself - definitely would be even more fab if it could be managed via admin some day.
Also FWIW - I am currently testing HESK with a Joomla 1.6 install, running in an iFrame - just to see if I could cheese a quick customization that way, and it's working/looking fine so far.

Thanks for a great product!
Christina G
colin65
Posts: 2
Joined: Thu May 05, 2011 3:58 am

Re: HESK e-mail piping public BETA (test version)

Post by colin65 »

For the benefit of anyone wanting to duplicate my email piping hack ... here is my modified code. Please be gentle .. I'm not a PHP programmer so if you have fixes or improvements I'd really appreciate them.

For some reason I could not make my new code work if I included the hesk_dbEscape wrapper around the column names. Probably missed something simple so, if you're more familiar with PHP than I am, please post a modification that works. :)

However, this has been working reliably for me for a while now ..

This is the modified section of /inc/mail/hesk_pipe.php ..

Code: Select all

/* parse the incoming e-mail */
$results = parser();

/* Variables */
$categorymail = $results['to'][0]['address'];
if ($categorymail) {
   $sql = "SELECT `category_id` FROM `".$hesk_settings['db_pfix']."category_email` WHERE `email` = '".$categorymail."' LIMIT 1";
   $result = hesk_dbQuery($sql);
}

if ($myresult = hesk_dbFetchAssoc($result)) {
   if ($myresult['category_id']) {
      $tmpvar['category'] = $myresult['category_id'];
   }
}
else {
   $tmpvar['category'] = 1;
}

$tmpvar['name']	    = hesk_input($results['from'][0]['name']) or $tmpvar['name'] = $hesklang['unknown'];
$tmpvar['email']	= hesk_validateEmail($results['from'][0]['address'],'ERR',0);
$tmpvar['priority'] = 3;
$tmpvar['subject']  = hesk_input($results['subject']) or $tmpvar['subject'] = '['.$hesklang['unknown'].']';
$tmpvar['message']  = hesk_input($results['message']);
$_SERVER['REMOTE_ADDR'] = $hesklang['unknown'];
$IS_REPLY = 0;
$trackingID = '';

For this code to work you'll need to create the category_email table in your Hesk database (don't forget to add your hesk prefix - default naming would be hesk_category_email). I did this via cpanel / phpmyadmin (at the bottom of the "structure" tab). You'll need two fields in your table.

category_id (smallint) - this is your primary key
email (varchar(150)) - this holds the email address (make this whatever length you feel is appropriate).

I also added a unique index on the email field so that each email address can only be associated with a single category.

Lastly, I noticed some strange behaviour in the parsing of the email body when creating the ticket. I modified the regular expression substitution in the file email_parser.php ... I think the replacement of newline characters was broken so that it replaced occurrences of "rs" or "ns" instead (just a guess). Anywhere this character sequence appeared we got strange unprintable chars in the ticket.

I also tried to preserve HTML break tags as new lines in the text of the ticket (eg. <br />). Here's my modified function ... please feel free to correct it.

Code: Select all

function convert_html_to_text($data)
{
  $search = array ("'<script[^>]*?>.*?</script>'si",  // Strip out javascript
  		 "'<br>|<br />|<BR>|<BR />'i",     // Turn HTML break into newline
                 "'<[/!]*?[^<>]*?>'si",          // Strip out HTML tags
                 "'&(quot|#34);'i",                // Replace HTML entities
                 "'&(amp|#38);'i",
                 "'&(lt|#60);'i",
                 "'&(gt|#62);'i",
                 "'&(nbsp|#160);'i",
                 "'&(iexcl|#161);'i",
                 "'&(cent|#162);'i",
                 "'&(pound|#163);'i",
                 "'&(copy|#169);'i",
                 "'&#(d+);'e");                    // evaluate as php

  $replace = array ("",
  		 "\n",
                 "",
                 "\"",
                 "&",
                 "<",
                 ">",
                 " ",
                 chr(161),
                 chr(162),
                 chr(163),
                 chr(169),
                 "chr(\1)");

  return preg_replace($search, $replace, $data); 
}
I hope this helps ...
Promofinity
Posts: 2
Joined: Mon May 30, 2011 5:09 pm

Re: HESK e-mail piping public BETA (test version)

Post by Promofinity »

Hello
This is not a bug with the piping - But it is a problem with trying to pipe from Google Apps.
Operating system: Linux
PHP version: 5.2.15
MySQL version: 5.1.52

I have setup Hesk on a subdomain of my primary domain - All perfect (Thanks for a Great script).
I use Google apps for my primary domain and have not been able to find out how to forward an email to pipe to a script.
So - I decided to create an email on my subdomain and then set up a filter in Google apps to auto forward all emails sent to 'support@primarydomain.com' onto 'help@support.primarydomain.com'.

The problem with this is that (of course) when Hesk acknowledges the ticket to the sender it also send a copy to support@primarydomain.com

This creates a loop where my support@ email then forwards it to the help@support.primarydomain.com and off we go again. I ended up with 60+ tickets created before I realised - I have turned off the forward for now!

I realise I was a bit stupid to try this and wonder if anyone has a solution for Google Apps emails?

Many Thanks (I will buy a licence as soon as I have finished testing)
Kevin
Locked