Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

POP/IMAP Polling Not Working

I have been playing with this for hours. I've read these forums and Googled, but still no luck.

I have set up POP/IMAP polling, created a cron job, and checked all my settings to make sure polling is turned on and osTicket will not fetch mails from a gmail (Google Apps, actually) account. The settings are correct and I get no error messages. I have the log set to DEBUG mode and I see where my cron job executes in the log, but still nothing. I added this line into the crontab:
*/2 * * * * php /var/www/support/api/cron.php
Again, cron seems to be working. I can run it from the command line as well, which doesn't return anything. All the log says is "External cron job executed [] ".

I have tried using both POP and IMAP on the account (and it is enabled on Google's side). I have even set up my local email client for both POP and IMAP to make sure everything was working on Google's side. Firewall ports have been opened and everything seems to be working properly, but osTicket will not grab the emails.

Any ideas?

Comments

  • More Information

    Polling seems to only work when Auto Cron is turned on. So it seems as if cron.php is broken.
  • Make sure IMAP extension is installed and enabled on CLI php - For some host command line PHP (used by cron) uses different php.ini file.
  • All of my config files are symbolically linked to one file, so everything is the same.
  • Running the cron script from the command line using php5-cgi says 500 Internal Server Error.
  • Possible Solution!

    I might have found a way to make this work, but it takes quite a bit of work for something so simple. I had to go into the API settings, add a key and passphrase for the local IP address (127.0.0.1), then go into the crontab and instead of using:
    php5 /var/www/support/api/cron.php

    You have to use this instead:
    wget -q -O /dev/null --user-agent=527C27522FE311B195E2F83F47FADB8A http://localhost/support/api/cron.php


    I stumbled upon this by using running php5-cgi /path/to/cron.php and noticing that it gave me a 500 Internal Server Error. Then I tried it with wget, where I got a 403 Forbidden. So I went through the code and noticed that in order to pass an API key, you have to rewrite the user agent string with the key. I figured it wouldn't hurt anything to try, and that did the trick.

    I don't know why you need to supply an API key to run the cron.php file on the local machine, but that did the trick. I smell a bug!!!!! I've seen a couple other unanswered posts having the same issue as me, so I know it's not just me.

    So the final result in the crontab (sudo crontab -e) would be the following:
    */5 * * * * wget -q -O /dev/null --user-agent=527C27522FE311B195E2F83F47FADB8A http://localhost/support/api/cron.php

    But you have to replace the the API key above with the key that gets generated when create the API key for your localhost (127.0.0.1).

    Hope this helps others experiencing the same issue.
  • Cli != cgi

    Besides what has been said, please, do not confuse php-cli with php-cgi. The CLI version of PHP is not the same as the CGI version.
  • osticket not fetching email when not logged in

    2 hours later and I finally found this post! Godsend. Let me dumb this down a bit for the lay person who is installing osTicket (like myself) who may have searched for this answer a little differently.

    Ok so here was my deal... I noticed that osTicket does not fetch email from POP or IMAP unless I or someone else is logged onto the Admin portion of osTicket. After researching this I found a lot of answers that seemed to indicate using lynx path/to/api/cron.php would work. I tried that every which way I could using //localhost and //domain.com and //ip.addr none of them worked. I always got 77 returned as an error which has something to do with the API credentials. So then I stumbled upon the post above, it's the solution you're looking for if you have this problem so take the time to read it carefully and do what it says. If you're using a new install of osTicket and you haven't been in the API section yet, it's under settings then click on the API icon. Delete the default entry that exists then after you have done that, fill in the required field and use the generated API key as your --user-agent string (see previous post with link). One more thing, if you try accessing your cron.php file using http://localhost and all that happens is that is comes back to the terminal prompt real quick then you need to use your internal IP address instead of //localhost. Worth noting.. You should run the wget command (with all of the options specified in the link provided in previous post remembering to use YOUR newly generated API key instead of what's displayed in the post before you add the cronjob. OK, once this gets indexed by GOOG it should help a lot of people who were in my situation.

    - IWBAM
  • Webmin --> Scheduled Cron Jobs

    Also worth noting... If you're used to using Webmin to administer your server then you can easily add the cron job using Webmin. System --> Scheduled Cron jobs (configure the job so it logs in as root).

    - IWSBAM
  • Another possibility

    I had a very similar issue to the original poster - error 500 (Internal Server Error) on only one of my osTicket deployments. It was only happening in the cron/autocron. I traced it down to needing the mbstring PHP module since the script was failing on the imap_utf8 function call.

    Hopefully this helps someone else.
  • this thread should really be stickied and laminated.

    Also, wouldn't hurt if an example of a cron command (WITH API KEY) was included in the documentation for setup of a cron job.

    Also worth noting:
    This not only works when you need to run your cron job from "the local IP address (127.0.0.1)"... it also works from any remote machine, as long as the remote machine has a fixed IP address, and you create an API key for that IP address.

    In my case, i am running ost on a windows server, so no cron. I also didn't like autocron for the reasons many people mention (when unattended, etc). It is also on a shared host, so no task-scheduler available or anything.

    ...but I have another hosting account for another domain on a linux server.

    So, using the correct syntax for the wget command, including the API key, I am able to run the cron job from the linux box, and have it access and perform the cron for the windows-based ost installation.

    I first had this working by hacking out the security that prevented it inside the api.inc.php ... but after reading this post and finding the correct way to use the API key, I now have closed that security hole, and it still works like a charm.
  • Yep, just wanted to report that this worked for me as well. I originally tried to go the standard documented route of simply calling the cron.php script from the cli directly using php, however, I wasn't ever able to get this to work. On the other hand, auto-cron was working OK, so I knew my mail settings were OK, but it wasn't feasible to only retrieve messages when staff were logged in.

    Evidently, from what I have read around the net, there may be some other things getting in the way such as which php.ini is being used when calling php from the cli, and if you're on a shared host like I am, it can make it difficult to troubleshoot. Using the wget method with the API key will guarantee that it's using the same, working method that auto-cron is using.

    Simply set up an API key in your osTicket installation's admin settings for the public IP for the server. Then call the following:

    wget -q -O /dev/null --user-agent= http://
    /api/cron.php

    Thanks again for the tip guys!

    jph;18382 said:this thread should really be stickied and laminated.

    Also, wouldn't hurt if an example of a cron command (WITH API KEY) was included in the documentation for setup of a cron job.

    Also worth noting:
    This not only works when you need to run your cron job from "the local IP address (127.0.0.1)"... it also works from any remote machine, as long as the remote machine has a fixed IP address, and you create an API key for that IP address.

    In my case, i am running ost on a windows server, so no cron. I also didn't like autocron for the reasons many people mention (when unattended, etc). It is also on a shared host, so no task-scheduler available or anything.

    ...but I have another hosting account for another domain on a linux server.

    So, using the correct syntax for the wget command, including the API key, I am able to run the cron job from the linux box, and have it access and perform the cron for the windows-based ost installation.

    I first had this working by hacking out the security that prevented it inside the api.inc.php ... but after reading this post and finding the correct way to use the API key, I now have closed that security hole, and it still works like a charm.
  • Cron JOB of KingHost in Brazil

    Guys,

    In this situation ? it supposed to work ?

    Please see the image below

    image

    Att.

    Guilherme
  • Oi Guilherme,
    This will execute daily at 1pm (13h), do you want to run this only once per day?

    The option we run is */5 * * * * that will run every 5 minutes.
  • ryanp;21798 said:
    Oi Guilherme,
    This will execute daily at 1pm (13h), do you want to run this only once per day?
    The trouble is that i can't insert key as $_GET parameter.

    Maybe some modification at api.inc.php on line 72 and 73.

    $ip=$_SERVER['REMOTE_ADDR'];
    $key=$_SERVER['HTTP_USER_AGENT']; //pulling all tricks.


    Transform it


    $ip='xxx.xxx.xxx.xx';
    $key='S92NS929SDSDKAN1O2OH123IHO1H23O123';


    or


    $ip= $_GET['ip'];
    $key=$_GET['key'];
  • Where is your SMTP hosted?

    What are the specific errors you're getting mate?
  • Hi Bro,

    I'm at kinghost.com.br

    I found the they have SSH.

    Here we go:

    User: zeferinodias
    Linux Pah: www/chamados/api/cron.php
    Web Path: www.zeferinodias.com.br/chamados/api/cron.php
    Key: 5BC6F8868A5F009FF12C670278DF0611


    I tried this but did not work.. i think i'm almost there:


    */5 * * * * nobody wget -q -O /www/ --zeferinodias-agent=5BC6F8868A5F009FF12C670278DF0611 http://zeferinodias.com.br/chamados/api/cron.php


    It says the file or diretory was not found
  • not working with me :(

    I have done so what deejross proposed, but email fetch are not working.

    I have configured osTicket v1.6 on windows, but my need is to make it available on Linux (FC) .

    I have configured whatever found on web, but failed to connect to pop server.

    I can send email from system but fetch is not working.

    on email setting, when I pass pop with ssl, it say ssl/tls negotiation failed.
    what i select no ssl, it say timeout.

    this is really mess :(

    can someone help me what should I check ?
  • My solution

    I know this is an old thread, but I also know loads of people are looking into this problem.

    MY SOLUTION: I opened my cron.php and my api.inc.php inside the API folder. Scroll to the bottom and remove the blank line(s) after the closing ?>

    These cause "header output already provided by" errors that do not show up in the crons. SO, by fixing those, I got my email working again!!!

    Hopefully it works for some.
  • deejross - Thank you. This finally did it for me.. It was such a struggle to get done. Off to the races!
  • Just a quick warning.. Gmail/GoogleApps isn't a normal email service, If you abuse it, or they think you are abusing it, they will block you!

    This is my crontab entry for Gmail polling:

    # Every Ten Minutes.. Google doesn't like it if you do too many!
    # Only during office-hours, Google makes you use a captcha
    # if you use automated tools to access their network.. so hide in normal traffic
    */10 8-18 * * 1-5 nobody /usr/bin/php /path/to/api/cron.php
    # Allow incoming on w/end.. at 30m intervals in afternoon
    */30 13-15 * * 6-7 nobody /usr/bin/php /path/to/api/cron.php


    I'm thinking of setting up an email server just for osTickets and getting google to forward all tickets.. thus saving a poll request and the damn captcha hell.. users will whinge.. is not very nice.
Sign In or Register to comment.