SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Imap not working in cron, working in browser

    Hi all,
    I have a script which i run by cron every 5 minutes. Script contains Imap function to grab mails from a window remote server. I am stuck here, because whenever i run it under cron it throw an error stating that:
    Fatal error: Call to undefined function imap_open() in
    But if i run the same script from a browser, it works and download the mails.

    I did a test something like to see whether imap is loaded or not:
    PHP Code:
    <?php

    echo "<pre>".implode("\n",get_loaded_extensions())."</pre>";

    dl("imap.so");
    if (
    extension_loaded("imap")) echo "<pre>imap loaded</pre>";
    else echo 
    "<pre>imap not loaded</pre>";

    ?>
    It shows that imap is loaded:
    zip
    xmlwriter
    libxml
    xml
    wddx
    tokenizer
    sysvshm
    sysvsem
    sysvmsg
    session
    SimpleXML
    sockets
    soap
    SPL
    shmop
    standard
    Reflection
    posix
    mime_magic
    mbstring
    json
    iconv
    hash
    gettext
    ftp
    filter
    exif
    dom
    dba
    date
    ctype
    calendar
    bz2
    bcmath
    zlib
    pcre
    openssl
    xmlreader
    apache2handler
    imap
    mcrypt
    mysql
    mysqli
    PDO
    pdo_mysql


    Warning: dl() [function.dl]: Dynamically loaded extensions aren't enabled in /var/www/pocslope/home/imap_load.php on line 5

    imap loaded
    Its a dedicated server running Ubuntu 8.04LTS server edition.
    I tried to install C-client module, its installed already now. PHPinfo is showing that imap is installed with C-client 2004 module. Also installed php-cli but no luck.
    Any ideas?
    Thanks

  2. #2
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    extension must be loaded in php.ini
    run script with phpinfo(), note php.ini location from it
    and then edit

  3. #3
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Shrapnel_N5,
    Before reading your post here, what i did were:
    I open php.ini on the server and search for "extension=imap.so"
    which was there and not commented, so it mean it was enabled. Then i open conf.d directory and look for imap.ini which was not there.
    So what i did:
    extension = imap.so
    And save the above line as a file named imap.ini and upload it to /etc/php5/conf.d directory and restart the server.
    And the great thing is, it works.

    Thanks again.
    Hope, it will be helpful for some one in future.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •