Copyright (c) 2006-2013 osTicket http://www.osticket.com Released under the GNU General Public License WITHOUT ANY WARRANTY. See LICENSE.TXT for details. vim: expandtab sw=4 ts=4 sts=4: **********************************************************************/ # Configuration: Enter the url and key. That is it. # url => URL to api/tickets.email e.g http://yourdomain.com/support/api/tickets.email # key => API's Key (see admin panel on how to generate a key) # // Home //~ $config = array( //~ 'url'=>'http://"IP"/ost/upload/api/tickets.email', //~ 'key'=>'fakekey' //~ ); $config = array( 'url'=>'http://"IP:port"/ost/upload/api/tickets.email', 'key'=>'fakekey' ); #pre-checks function_exists('file_get_contents') or die('upgrade php >=4.3'); function_exists('curl_version') or die('CURL support required'); #read stdin (piped email) #$data=file_get_contents('php://stdin') or die('Error reading stdin. No message'); $randnum = mt_rand(10000000,99999999); $data2 = array( 'correo' => $_POST["correo"], //CORREO 'cc' => $_POST["cc_send"], //TITULO 'tid' => $_POST["ticketid"] ); // ATENTTION!!!! //To direction its important, need to be the real osticket mail sender/receiver. //********************************* $data= ' From: <'.$data2['correo'].'> To: osticketmail@mail.com Cc: '.$data2['cc'].' Message-ID: <449788690.1920691.1433853'.$randnum.'.JavaMail.zimbra@mail.com> Subject: '.$data2['tid'].' MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2341615_1143171033.1433853426024" ------=_Part_2341615_1143171033.1433853426024 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Colaboradores Agregados '; echo $data; #set timeout set_time_limit(10); #curl post $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $config['url']); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_USERAGENT, 'osTicket API Client v1.7'); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Expect:', 'X-API-Key: '.$config['key'])); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $result=curl_exec($ch); curl_close($ch); //Use postfix exit codes...expected by MTA. $code = 75; if(preg_match('/HTTP\/.* ([0-9]+) .*/', $result, $status)) { switch($status[1]) { case 201: //Success $code = 0; break; case 400: $code = 66; break; case 401: /* permission denied */ case 403: $code = 77; break; case 415: case 416: case 417: case 501: $code = 65; break; case 503: $code = 69; break; case 500: //Server error. default: //Temp (unknown) failure - retry $code = 75; } } exit($code); ?>