Page 2 of 5

No Message

Posted: Wed Jun 03, 2009 6:51 pm
by Chako
Hi,

I also tried to work with the new script.
All in all it works fine but I have one big Problem: I don't see a Message in the Hesk-System. I do see the Subject and a Ticket-ID but when I open the new created Ticket there is no message.
It looks like (It's the german-version):
Datum: 3-Jun-2009 20:52:18
Name: Markus
E-Mail: markus@xxx.de
IP: email

Kundennummer:
Benutzername:

Nachricht:
(Nachricht would be translated "message" - and there is no message.)


Does anyone have an idea why there is the message missing?
--
Another thing: When I send an E-Mail out of Outlook to the Ticketsystem the Subject looks good. But when I send an E-Mail from the Confixx Webinterface to the Ticket-System I have the charset-Error... (postings above).
---

And for some people who want an updated imap.php with some changes because of the postings above here is it (please search for "yourdomain.com" in the Script and paste your real serverhost (LINE 42)):

Code: Select all

<?php 
// Settings ///////////////////////////////////////////////////////////////////////////////// 
$server               = "mail.yourdomain.com"; //mail server. 
$user                 = "web1p1"; // Mail Username 
$password             = "password"; // Mail Password 
$delete               = "Y";  // if delete is Y then processed mail will be deleted 
$debug                = 1; // Display Notices about in/outgoing emails 1 = on | 0 = off 
$category         = 1; // Hesk Category ID to trow all emails in 
$priority         = 2; // 3=Low 2=Medium 1=High 
///////////////////////////////////////////////////////////////////////////////////////////// 
define('IN_SCRIPT',1); 
if (!function_exists('imap_open')) die("IMAP functions are not available."); 
if ($debug==1) error_reporting(E_ALL); else error_reporting(0); 
// Get all the required files and functions 
require_once('hesk_settings.inc.php'); 
require_once('language/'.$hesk_settings['language'].'.inc.php'); 
require_once('inc/common.inc.php'); 
// Connect to database 
require_once('inc/database.inc.php'); 
hesk_dbConnect() or hesk_error("$hesklang[cant_connect_db] $hesklang[contact_webmsater] $hesk_settings[webmaster_mail]!"); 

// Functions 
function getHeader($msgStream, $msgNumber) { 
  // strips the mail header and places everything in an array .. like from name, from email, date and subject 
  $mailheader = imap_headerinfo($msgStream, $msgNumber); 
  $headerArray = array(); 
  $headerArray[0] = $mailheader->subject; 
  $from = $mailheader->from; 
  foreach ($from as $id => $object) { 
    $headerArray[1]  = $object->personal;  // from personal 
    $headerArray[2]  = $object->mailbox . "@" . $object->host;  // from address 
  } 
  $headerArray[3] = $mailheader->Date; 
  return $headerArray; 
} 
function getBody($msgStream, $msgNumber){ 
   // gets email content 
   $body=imap_body($msgStream,$msgNumber); 
   return $body; 
} 

$host = "{mail.yourdomain.com:143/imap/notls}INBOX"; 

//connect to inbox and check for new msgs 
$msgStream = imap_open($host, $user, $password) or die("<br><br><b>Error: Can't connect to mailbox</b>"); 
$check = imap_mailboxmsginfo($msgStream); 
$number = $check->Nmsgs; 
if ($debug==1) { 
    echo "<b>Notices (".date("H:i:s")."):</b><br>"; 
    if ($number>0) { 
        echo "<b> - ".$number." email(s)</b><br>"; 
    } else { 
        echo "<b> - No Email in Inbox</b><br>"; 
    } 
    $mbox = imap_open("{".$server.":143/imap/notls}", $user, $password); 
    echo "<h1>Mailboxes</h1>\n"; 
    $folders = imap_listmailbox($mbox, "{".$server."}", "*"); 
    if ($folders == false) { 
   echo "imap_listmailbox failed<br />\n"; 
    } else { 
   foreach ($folders as $val) { 
       echo $val . "<br />\n"; 
   } 
    } 
    echo "<h1>Headers in INBOX</h1>\n"; 
    $headers = imap_headers($mbox); 
    if ($headers == false) { 
   echo "imap_headers failed<br />\n"; 
    } else { 
   foreach ($headers as $val) { 
       echo $val . "<br />\n"; 
   } 
    } 
    imap_close($mbox); 
} 

$msgNumber = "1"; 
while ($msgNumber <= $number) { 
   $headerArray = getHeader($msgStream, $msgNumber); 
   $message = htmlentities(getBody($msgStream, $msgNumber)); 
   $subject = htmlentities($headerArray[0]); 
   $name    = htmlentities($headerArray[1]); 
   $email   = htmlentities($headerArray[2]); 
   $date    = htmlentities($headerArray[3]); 
   // Generate tracking ID 
   $useChars='AEUYBDGHJLMNPQRSTVWXZ123456789'; 
   $trackingID = $useChars{mt_rand(0,29)}; 
   for($i=1;$i<10;$i++) $trackingID .= $useChars{mt_rand(0,29)}; 
   $trackingURL=$hesk_settings['hesk_url'].'/ticket.php?track='.$trackingID; 
   // End Generate tracking ID 
   $sql = " 
   INSERT INTO `hesk_tickets` ( 
   `trackid`,`name`,`email`,`category`,`priority`,`subject`,`message`,`dt`,`lastchange`,`ip`,`status`,`attachments`,`custom1`,`custom2`,`custom3`,`custom4`,`custom5` 
   ) 
   VALUES ( 
   '$trackingID','$name','$email','$category','$priority','$subject','$message',NOW(),NOW(),'email','0','','','','','','' 
   ) 
   "; 
   $result = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]"); 
   // Get e-mail message for customer 
   $fp=fopen('emails/new_ticket.txt','r'); 
   $message=fread($fp,filesize('emails/new_ticket.txt')); 
   fclose($fp); 
   $message=str_replace('%%NAME%%',$name,$message); 
   $message=str_replace('%%SUBJECT%%',$subject,$message); 
   $message=str_replace('%%TRACK_ID%%',$trackingID,$message); 
   $message=str_replace('%%TRACK_URL%%',$trackingURL,$message); 
   $message=str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'] ,$message); 
   $message=str_replace('%%SITE_URL%%',$hesk_settings['site_url'] ,$message); 
   // Send e-mail 
   $headers="From: $hesk_settings[noreply_mail]\n"; 
   $headers.="Reply-to: $hesk_settings[noreply_mail]\n"; 
   @mail($email,$hesklang['ticket_received'],$message,$headers); 
   // Need to notify any admins? 
   $admins=array(); 
   $sql = "SELECT `email`,`isadmin`,`categories` FROM `hesk_users` WHERE `notify`='1'"; 
   $result = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]"); 
   while ($myuser=hesk_dbFetchAssoc($result)) { 
       // Is this an administrator? 
       if ($myuser['isadmin']) {$admins[]=$myuser['email']; continue;} 
       // Not admin, is he allowed this category? 
       $cat=substr($myuser['categories'], 0, -1); 
       $myuser['categories']=explode(',',$cat); 
       if (in_array($category,$myuser['categories'])) { 
      $admins[]=$myuser['email']; continue; 
       } 
   } 
   if (count($admins)>0) { 
   $trackingURL_admin=$hesk_settings['hesk_url'].'/admin/admin_ticket.php?track='.$trackingID;
      // Get e-mail message for customer 
      $fp=fopen('emails/new_ticket_staff.txt','r'); 
      $message=fread($fp,filesize('emails/new_ticket_staff.txt')); 
      fclose($fp); 
      $message=str_replace('%%NAME%%',$name,$message); 
      $message=str_replace('%%SUBJECT%%',$subject,$message); 
      $message=str_replace('%%TRACK_ID%%',$trackingID,$message); 
      $message=str_replace('%%TRACK_URL%%',$trackingURL_admin,$message); 
      $message=str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'] ,$message); 
      $message=str_replace('%%SITE_URL%%',$hesk_settings['site_url'] ,$message); 
      // Send e-mail to staff 
      $email=implode(',',$admins); 
      $headers="From: $hesk_settings[noreply_mail]\n"; 
      $headers.="Reply-to: $hesk_settings[noreply_mail]\n"; 
      @mail($email,$hesklang['new_ticket_submitted'],$message,$headers); 
   } // End if 
   if ($delete == "Y") imap_delete($msgStream, $msgNumber);  // mark the current message for deletion 
   $msgNumber++; 
} 
if ($delete == "Y") imap_expunge($msgStream);  // delete all messages marked for deletion 
imap_close($msgStream); 
?>

Posted: Fri Sep 11, 2009 5:22 pm
by Chako
No new ideas?

Posted: Fri Sep 11, 2009 7:34 pm
by Klemen
Use %%MESSAGE%% in Hesk version 2.1

Posted: Wed Nov 04, 2009 11:08 pm
by hollandsedrop
I received HTTP 500 fault. Any idea?

Posted: Sun Nov 15, 2009 11:58 am
by hollandsedrop
Hi,
this addon work 2.1?

I can not run.

500 Internal Server Error

Posted: Fri Dec 04, 2009 2:52 pm
by hollandsedrop
I received that fault. Do you have any idea?

HTTP request sent, awaiting response... 500 Internal Server Error
06:50:02 ERROR 500: Internal Server Error.

New version

Posted: Sat Jan 02, 2010 11:58 pm
by perfh
Hello !

New version with much bugfix. This version work fine with Hesk 2.1

Code: Select all

<?php 

////////////////////////////////////////// Settings //////////////////////////////////////////
$server               = "pop.yourdomain.com"; //mail server. 
$user                 = "yourusername"; // Mail Username 
$password             = "yourpassword"; // Mail Password 
$delete               = "Y";  // if delete is Y then processed mail will be deleted 
$debug                = 0; // Display Notices about in/outgoing emails 1 = on | 0 = off 
$category         = 1; // Hesk Category ID to trow all emails in 
$priority         = 3; // 3=Low 2=Medium 1=High 
///////////////////////////////////////////////////////////////////////////////////////////// 

define('IN_SCRIPT',1);
define('HESK_PATH',''); 

if (!function_exists('imap_open')) die("IMAP functions are not available."); 
if ($debug==1) error_reporting(E_ALL); else error_reporting(0); 

// Get all the required files and functions 
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');

// Connect to database 
require(HESK_PATH . 'inc/database.inc.php');

hesk_dbConnect() or hesk_error("$hesklang[cant_connect_db] $hesklang[contact_webmsater] $hesk_settings[webmaster_mail]!"); 

// Functions 
function getHeader($msgStream, $msgNumber) { 
  // strips the mail header and places everything in an array .. like from name, from email, date and subject 
  $mailheader = imap_headerinfo($msgStream, $msgNumber); 
  $headerArray = array(); 
  $headerArray[0] = $mailheader->subject; 
  $from = $mailheader->from; 
  foreach ($from as $id => $object) { 
    $headerArray[1]  = $object->personal;  // from personal 
    $headerArray[2]  = $object->mailbox . "@" . $object->host;  // from address 
  } 
  $headerArray[3] = $mailheader->Date;
  return $headerArray; 
} 

$host = "{".$server.":143"."}"."INBOX"; 

//connect to inbox and check for new msgs 
$msgStream = imap_open($host, $user, $password) or die("<br><br><b>Error: Can't connect to mailbox</b>"); 
$check = imap_mailboxmsginfo($msgStream); 
$number = $check->Nmsgs; 
if ($debug==1) { 
    echo "<b>Notices (".date("H:i:s")."):</b><br>"; 
    if ($number>0) { 
        echo "<b> - ".$number." email(s)</b><br>"; 
    } else { 
        echo "<b> - No Email in Inbox</b><br>"; 
    } 
    $mbox = imap_open("{".$server.":143}", $user, $password); 
    echo "<h1>Mailboxes</h1>\n"; 
    $folders = imap_listmailbox($mbox, "{".$server."}", "*"); 
    if ($folders == false) { 
   echo "imap_listmailbox failed<br />\n"; 
    } else { 
   foreach ($folders as $val) { 
       echo $val . "<br />\n"; 
   } 
    } 
    echo "<h1>Headers in INBOX</h1>\n"; 
    $headers = imap_headers($mbox); 
    if ($headers == false) { 
   echo "imap_headers failed<br />\n"; 
    } else { 
   foreach ($headers as $val) { 
       echo $val . "<br />\n"; 
   } 
    } 
    imap_close($mbox); 
} 

$msgStream = imap_open($host, $user, $password) or die("<br><br><b>Error: Can't connect to mailbox</b>");
$msgNumber = "1"; 

while ($msgNumber <= $number) { 
   $headerArray = getHeader($msgStream, $msgNumber); 
   $message = htmlentities(addslashes(imap_body($msgStream, $msgNumber))); 
   $subject = htmlentities(addslashes($headerArray[0])); 
   $name    = htmlentities(addslashes($headerArray[1])); 
   $email   = htmlentities($headerArray[2]); 
   $date    = htmlentities($headerArray[3]); 
   // Generate tracking ID 
   $useChars='AEUYBDGHJLMNPQRSTVWXZ123456789'; 
   $trackingID = $useChars{mt_rand(0,29)}; 
   for($i=1;$i<10;$i++) $trackingID .= $useChars{mt_rand(0,29)}; 
   $trackingURL=$hesk_settings['hesk_url'].'/ticket.php?track='.$trackingID; 
   // End Generate tracking ID
   $sql = " 
   INSERT INTO `hesk_tickets` ( 
   `trackid`,`name`,`email`,`category`,`priority`,`subject`,`message`,`dt`,`lastchange`,`ip`,`status`,`attachments`,`custom1`,`custom2`,`custom3`,`custom4`,`custom5`
   ) 
   VALUES ( 
   '$trackingID','$name','$email','$category','$priority','$subject','$message',NOW(),NOW(),'email','0','','','','','','' 
   ) 
   "; 
   $result = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]"); 
   // Get e-mail message for customer 
   $fp=fopen('language/'.$hesk_settings['languages'][$hesk_settings['language']]['folder'].'/emails/new_ticket.txt','r'); 
   $message=fread($fp,filesize('language/'.$hesk_settings['languages'][$hesk_settings['language']]['folder'].'/emails/new_ticket.txt')); 
   fclose($fp); 
   $message=str_replace('%%NAME%%',$name,$message); 
   $message=str_replace('%%SUBJECT%%',$subject,$message); 
   $message=str_replace('%%TRACK_ID%%',$trackingID,$message); 
   $message=str_replace('%%TRACK_URL%%',$trackingURL,$message); 
   $message=str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'] ,$message); 
   $message=str_replace('%%SITE_URL%%',$hesk_settings['site_url'] ,$message); 
   // Send e-mail 
   $headers="From: $hesk_settings[noreply_mail]\n"; 
   $headers.="Reply-to: $hesk_settings[noreply_mail]\n"; 
   @mail($email,$hesklang['ticket_received'],$message,$headers); 
   // Need to notify any admins? 
   $admins=array(); 
   $sql = "SELECT `email`,`isadmin`,`categories` FROM `hesk_users` WHERE `notify`='1'"; 
   $result = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]"); 
   while ($myuser=hesk_dbFetchAssoc($result)) { 
       // Is this an administrator? 
       if ($myuser['isadmin']) {$admins[]=$myuser['email']; continue;} 
       // Not admin, is he allowed this category? 
       $cat=substr($myuser['categories'], 0, -1); 
       $myuser['categories']=explode(',',$cat); 
       if (in_array($category,$myuser['categories'])) { 
      $admins[]=$myuser['email']; continue; 
       } 
   } 
   if (count($admins)>0) { 
      $trackingURL_admin=$hesk_settings['hesk_url'].'/admin/admin_ticket.php?track='.$trackingID; 
      // Get e-mail message for customer 
      $fp=fopen('language/'.$hesk_settings['languages'][$hesk_settings['language']]['folder'].'/emails/new_ticket_staff.txt','r'); 
      $message=fread($fp,filesize('language/'.$hesk_settings['languages'][$hesk_settings['language']]['folder'].'/emails/new_ticket_staff.txt')); 
      fclose($fp); 
      $message=str_replace('%%NAME%%',$name,$message); 
      $message=str_replace('%%SUBJECT%%',$subject,$message); 
      $message=str_replace('%%TRACK_ID%%',$trackingID,$message); 
      $message=str_replace('%%TRACK_URL%%',$trackingURL_admin,$message); 
      $message=str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'] ,$message); 
      $message=str_replace('%%SITE_URL%%',$hesk_settings['site_url'] ,$message); 
      // Send e-mail to staff 
      $email=implode(',',$admins); 
      $headers="From: $hesk_settings[noreply_mail]\n"; 
      $headers.="Reply-to: $hesk_settings[noreply_mail]\n"; 
      @mail($email,$hesklang['new_ticket_submitted'],$message,$headers); 
   } // End if 
   if ($delete == "Y") imap_delete($msgStream, $msgNumber);  // mark the current message for deletion 
   $msgNumber++; 
} 
if ($delete == "Y") imap_expunge($msgStream);  // delete all messages marked for deletion 
imap_close($msgStream); 

?>

Posted: Sun Jan 03, 2010 1:15 am
by hollandsedrop
Error: Can't connect to mailbox

Posted: Sun Jan 03, 2010 10:33 am
by perfh
Your server or user or password was not correctly informed.

Posted: Sun Jan 03, 2010 8:09 pm
by hollandsedrop
It needs to have authentication enabled.

Posted: Thu Jan 28, 2010 2:31 pm
by hanstroost
hollandsedrop wrote:Error: Can't connect to mailbox
Hi, I had the same problem, but now it's working.
Problem was the at username I had to add @domainname.com
For example user@domail.com

Posted: Thu Jan 28, 2010 2:37 pm
by hollandsedrop
hanstroost wrote:
hollandsedrop wrote:Error: Can't connect to mailbox
Hi, I had the same problem, but now it's working.
Problem was the at username I had to add @domainname.com
For example user@domail.com

already in this way, but not work :(

all chars

Posted: Thu Jan 28, 2010 2:53 pm
by hanstroost
Hi,

If I sent a mail for Outlook the tickets are created like this below.

--_000_42A27C666486E746BD0C6A60142EC3AB0321B958A4NTHVSEXCHMAIL_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable hello, this is a test. --_000_42A27C666486E746BD0C6A60142EC3AB0321B958A4NTHVSEXCHMAIL_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <html dir=3D"ltr"><head> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-= 1"> <style title=3D"owaParaStyle">P { MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px } </style> </head> <body ocsi=3D"x"> <div dir=3D"ltr"><font color=3D"#000000" size=3D"2" face=3D"Tahoma">hello,<= /font></div> <div dir=3D"ltr"><font size=3D"2" face=3D"tahoma"></font>&nbsp;</div> <div dir=3D"ltr"><font size=3D"2" face=3D"tahoma">this is a test.</font></div> </body> </html> --_000_42A27C666486E746BD0C6A60142EC3AB0321B958A4NTHVSEXCHMAIL_--

Have someone a solution?

Re: all chars

Posted: Fri Jan 29, 2010 8:40 am
by hollandsedrop
hanstroost wrote:Hi,

If I sent a mail for Outlook the tickets are created like this below.

--_000_42A27C666486E746BD0C6A60142EC3AB0321B958A4NTHVSEXCHMAIL_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable hello, this is a test. --_000_42A27C666486E746BD0C6A60142EC3AB0321B958A4NTHVSEXCHMAIL_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <html dir=3D"ltr"><head> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-= 1"> <style title=3D"owaParaStyle">P { MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px } </style> </head> <body ocsi=3D"x"> <div dir=3D"ltr"><font color=3D"#000000" size=3D"2" face=3D"Tahoma">hello,<= /font></div> <div dir=3D"ltr"><font size=3D"2" face=3D"tahoma"></font>&nbsp;</div> <div dir=3D"ltr"><font size=3D"2" face=3D"tahoma">this is a test.</font></div> </body> </html> --_000_42A27C666486E746BD0C6A60142EC3AB0321B958A4NTHVSEXCHMAIL_--

Have someone a solution?
any idea?

Re: all chars

Posted: Fri Jan 29, 2010 5:16 pm
by Petert
hollandsedrop wrote:
hanstroost wrote:Hi,

If I sent a mail for Outlook the tickets are created like this below.

--_000_42A27C666486E746BD0C6A60142EC3AB0321B958A4NTHVSEXCHMAIL_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable hello, this is a test. --_000_42A27C666486E746BD0C6A60142EC3AB0321B958A4NTHVSEXCHMAIL_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <html dir=3D"ltr"><head> <meta http-equiv=3D"Content-Type" <snip lodas of Microsoft crap></html> --_000_42A27C666486E746BD0C6A60142EC3AB0321B958A4NTHVSEXCHMAIL_--

Have someone a solution?
any idea?
Problem is you have multi-part e-mails, but no plain text alternatives.
Use a real e-mail application.