No Message
Posted: Wed Jun 03, 2009 6:51 pm
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):
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)):
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):
(Nachricht would be translated "message" - and there is no message.)Datum: 3-Jun-2009 20:52:18
Name: Markus
E-Mail: markus@xxx.de
IP: email
Kundennummer:
Benutzername:
Nachricht:
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);
?>