PHP imap_open() error in command line
I am trying to run a PHP page from the command line which uses imap_open() to open an email inbox. The script works fine in the browser.
PHP Script:
$imap_stream = imap_open($host,$username,$pass);
Command:
php -c /etc/php.ini /home/public_html/inc/mailGet.php
Error:
PHP Fatal error: Call to undefined function imap_open() in /home/public_html/inc/mailGet.php on line 13
I included the correct php.ini with -c /etc/php.ini
in the command to make sure it was using the same .ini file as the browser. (this is the开发者_开发知识库 path to the .ini as stated in my phpinfo(); page).
I am running Apache2(Centos5.5) with PHP 5.2.6. Can anybody please advise?
Thank you,
Chris.
I have found i need to define the extension sometimes in my php.ini when using CLI-PHP. Try adding extension=imap.so to your php.ini and still include it with your command (-c /etc/php.ini)
I had to do the same thing for mysql by adding extension=mysql.so
Even though the extension will show in your phpinfo(); it doesnt always load in CLI PHP.
The IMAP functions are an extension. According to the manual, PHP needs to have been compiled with --with-imap[=DIR]
it doesn't seem to be in your case.
Maybe you have multiple instances of command line php
on your system?
As a last straw, if CLI PHP can't be equipped with the needed functions, I guess you could do a http request in your crontab:
wget http://localhost/path_to_script.php
精彩评论