3

I have just installed an osTicket server for our company and I have problem with creating tickets from email. I'm using Postfix as my SMTP server and Dovecot as my IMAP server.

In osTicket panel I don't get any error when configuring email setting. But when I sent an email to support@mydomain.com, it does not create any ticket in my osticket panel. I have checked my mail log and everything looks fine. I think there is something wrong with my "automail.php" file.

I will be very happy if you could help me. Thanks in advance.

automail.php file:

***
#!/usr/bin/php -q
<?php
/*********************************************************************
    automail.php

    PHP script used for remote email piping...same as as the perl version.

    Peter Rotich <peter@osticket.com>
    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)
#

$config = array(
        'url'=>'support.example.com/tickets.php',
        'key'=>'A12857AA982EEE5612EF8F2443538D76'
        );

#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');

#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);
?>

Diamond
  • 9,001
  • 3
  • 24
  • 38
Ati
  • 31
  • 1
  • 3
  • 1
    There are two methods for email fetching, Email Piping and POP3/IMAP Polling. They also both need further configuration. Have you done that? – Diamond Feb 22 '16 at 10:41
  • @bangal yes I did. – Ati Feb 23 '16 at 06:02
  • is the url correct? It should be something like: `http://www.yourdomain.com/osticket/api/tickets.email`.Have you enabled api access in osticket? – Diamond Feb 23 '16 at 09:42
  • from the beginning there was not a tickets.email in my osticket/api/ directory. I just found this tickets.php in the main directory of osticket. – Ati Feb 23 '16 at 09:46
  • You don't need the exact file there. Just add it as mentioned. Also make sure you have confiugred key and all: http://tmib.net/using-osticket-1812-api – Diamond Feb 23 '16 at 10:09
  • I didn't know that before. I did whatever you said, still does not create tickets. – Ati Feb 23 '16 at 11:57
  • How have you setup aliasing for piping in postfix? Post your config. – Diamond Feb 23 '16 at 12:29
  • I add this line in /etc/aliases -> support: |/tmp/automail.php – Ati Feb 23 '16 at 13:24
  • create a virtual alias first if you have virtual domain configured and dont forget to run newaliases after changing /etc/aliases file. check this: http://serverfault.com/questions/506894/how-to-route-email-to-a-script. Also note the spacing: `support: "| /tmp/automail.php"` – Diamond Feb 23 '16 at 14:02
  • I did all the thing you said but still there is no ticket with email. I'm pretty sure there is something wrong with my "automail.php". Do you know how can I run this file individually? I mean what is the input for this file? – Ati Feb 24 '16 at 09:48
  • You need to make sure first, the email alias is working, second, that the php script is called and run and third, the automail.php script is able to connect to the osticket server. Check step by step and see. The mail log, syslog etc. can help you pin point the problem. – Diamond Feb 26 '16 at 13:46
  • I really appreciate for your replies :) I can forward emails to another user's mailbox, but into a script? It does not work. – Ati Feb 29 '16 at 06:27

1 Answers1

2

According to the osTicket official documentation, there are two methods for email fetching: Email Piping and POP3/IMAP Polling. And they both require further configuration, which you are missing.

Routing Incoming Emails

Setting up your system to accept emails varies from system to system and depends on your personal preference. osTicket currently supports piping (aliases) and POP3/IMAP polling methods for routing incoming emails. Tickets are routed to the department and assigned a default priority associated with the email.

To enable incoming email fetching, in the Admin panel go to Settings and Email, and check the box for Email Fetching to enable it. It is disabled by default.

Email Piping

Piping method allows for real-time email handling. Extra setup is required at mail server level to pipe the raw email message to osTicket pipe handler. Both remote and local piping are supported. See Email Piping Guide.

POP3/IMAP Polling

POP3/IMAP account polling method is best suited for individuals with remote mail account(s) and/or with limited access to mail delivery settings. Each email address added to the system can have an account associated to it. See POP3/IMAP Setting Guide.

Diamond
  • 9,001
  • 3
  • 24
  • 38
  • I'm using Piping method with automail.php. There is not enough information to do that. I still think the problem is automail.php which can not deliver emails to osTicket server. could you please help. – Ati Feb 23 '16 at 07:44
  • Have you tried the other method: pop3/imap? It is simpler, so give it a try. As for the piping method, you will need to post more information to get help. – Diamond Feb 23 '16 at 08:05
  • I need to do it with Piping method. here is my "automail.php" file. I'm pretty sure the problem is this file. Add it to my question. – Ati Feb 23 '16 at 09:40