1. Kayako Download customers: we will continue to develop and support Kayako Download beyond July 2017, alongside the new Kayako for existing customers.

    Find out more.

  2. The forum you are viewing relates to Kayako Classic. If you signed up or upgraded to the new Kayako (after the 4th July 2016), the information in this thread may not apply to you. You can visit the forums for the new Kayako here.

Email Parser: IMAP Mail Queues with Microsoft Exchange

Discussion in 'Installation and setup (Kayako Classic Download)' started by Matt Muller, Aug 9, 2012.

  1. Matt Muller

    Matt Muller New Member

    Just downloaded and installed Kayako Resolve and went to set up IMAP email importing from our Exchange server. Whenever I tested the connection, I'd get the message Kerberos error: No credentials cache found (try running kinit) and the connection would fail.

    A little bit of Googling showed me that I wasn't the first person to experience this problem. Thanks to Technocrat and chrismorley, multiple Red Bulls, and a couple hours of pulling my hair out, I was able to get IMAP email import working on CentOS 6.3 x64 running PHP 5.3.3. If anyone running the same system wants the imap.so module for Apache, just let me know and I'd be happy to send it over. If you want to do it yourself, the instructions are below. I'm assuming that you're running a standard CentOS 64-bit install and everything is in default locations.

    First, you'll want to make sure you have all the necessary dependencies installed on your system. (Adding the EPEL repo is generally useful if you don't have it already):

    wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
    rpm -ivh epel-release-6-7.noarch.rpm
    yum groupinstall "Development Tools"
    yum install openssl-devel pam-devel libxml2-devel

    Next, you'll want to download the latest IMAP c-client and get that ready to compile:

    cd /usr/local
    wget ftp://ftp.cac.washington.edu/imap/c-client.tar.Z
    tar -xzf c-client.tar.Z
    rm -f c-client.tar.Z
    cd imap-2007f
    ln -s /usr/lib64/openssl/engines/ /usr/local/ssl
    ln -s /usr/include/ /usr/local/ssl/include
    Because this is a 64-bit system, you'll also want to edit the Makefile or you'll get an error down the road. Find the line that reads 'EXTRACFLAGS=' and change it to

    Now you'll actually compile the c-client and move the components into their correct locations - hooray, we're like almost halfway done!

    make lr5
    mkdir lib
    mkdir include
    cp c-client/*.c lib/
    cp c-client/*.h include/
    cp c-client/c-client.a lib/libc-client.a
    Now it's time for the PHP portion of this (don't forget to download the version of PHP that you're running):

    cd ~
    wget http://museum.php.net/php5/php-5.3.3.tar.gz
    tar -xzf php-5.3.3.tar.gz
    cd php-5.3.3
    ./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu --without-kerberos --with-imap=shared,/usr/local/imap-2007f/ --with-imap-ssl
    Hopefully there were no errors - if there are, it's probably related to a missing library. The last step is to swap out the existing IMAP module with the one you just compiled and restart Apache for it to take effect:

    cp /usr/lib64/php/modules/imap.so ~/imap.so.bak
    cp modules/imap.so /usr/lib64/php/modules/imap.so
    service httpd restart
    Hope that helped. Ultimately it took many, many hours, a lot of pain, and the following resources (who I am infinitely indebted to) to make this work.

    Jitender Kumar and Gary McGrath like this.
  2. Kevin Delaney

    Kevin Delaney New Member

    Matt you are my hero. Thank you SO much. I have spent almost 20 hours on this and your solution finally nailed it for me. THANK YOU!
  3. David H

    David H Established Member

    Just an FYI that might be easier than compiling imap modules (and recompiling them as versions change and security patches come out); we're running fetchmail on the unix side to pull mail from an Exchange server and dump it into a Courier-based IMAP server that our Kayako pulls from using the native redhat php-imap functionality.

    We didn't have the kerberos issue you did, rather we set this up because when we were pulling directly from Exchange, it never failed that perhaps once a week some message would come in that for whatever reason, Kayako's mail parser would barf on, leaving the message stuck on the Exchange server. So every few minutes when the cron job triggers the pull, it would try again, fail, repeat. No one would realize tickets had stopped coming in until someone would think hey, we haven't seen a ticket in a while. Then you have to check the exchange mailbox, find the email it doesn't like, delete it, wait.

    The fetchmail task makes it very easy to pull the mail from Exchange to a local mailbox. Additionally, it logs everything it does so you can easily tell why it's failing if it does fail. So far, over the course of a year, Kayako has never failed to retrieve a message from the Courier-based IMAP server while it seemed to fail all the time on the Exchange IMAP server.

    Anyone who wants to do such a setup, all you need in your centos/rhel install is the rpm's for procmail and fetchmail. Cron job for fetchmail looks something like this if you're running a mail server that uses Maildir format directories, such as qmail or postfix:

    */5 * * * * export FETCHMAILHOME="/home/support/fetchmail-log"; /usr/bin/fetchmail -f /home/support/fetchmail-support.conf

    The first directory is just where the logs get written, the second is a path to the config file. The config file contains:

    set logfile /home/support/fetchmail-log/support.log
    set invisible
    set no bouncemail

    poll "exchangeserver.domain"
    protocol IMAP
    username "email-user"
    password "email-pass"
    mda "/usr/bin/procmail -m /home/support/procmail-support.conf"

    So that basically tells fetchmail where to log, the Exchange server name and credentials, imap protocol, use SSL, fetch everything, don't leave copies, and execute procmail to deliver the messages. The procmail config says:



    This causes the messages to be written in Maildir format to /home/support/Maildir/new/ per the Maildir standard. Procmail also writes a log of the deliveries. Makes debugging real easy.

    I realize this sounds a little complex but it only takes a few minutes since you can install the rpm's via yum and then it's just filling in the blanks. This of course assumes you already have an imap server running on unix somewhere that you can write the messages to. Gets a lot more complex if you have to set up an imap server.

Share This Page