Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Nov 8, 2009, 21:42   #1
mmarif4u
SitePoint Evangelist
 
mmarif4u's Avatar
 
Join Date: Dec 2006
Location: /dev/swat
Posts: 536
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:
Quote:
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:
Quote:
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
mmarif4u is offline   Reply With Quote
Old Nov 8, 2009, 23:17   #2
Shrapnel_N5
SitePoint Evangelist
 
Shrapnel_N5's Avatar
 
Join Date: Oct 2009
Posts: 463
extension must be loaded in php.ini
run script with phpinfo(), note php.ini location from it
and then edit
Shrapnel_N5 is online now   Reply With Quote
Old Nov 8, 2009, 23:37   #3
mmarif4u
SitePoint Evangelist
 
mmarif4u's Avatar
 
Join Date: Dec 2006
Location: /dev/swat
Posts: 536
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:
Quote:
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.
mmarif4u is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 16:08.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved