0

I am running Windows Server 2012, and is also running apache and PHP on an intranet.

When I pull the script through http://localhost/script.php it runs without issue and no problems.

When I run the same script through the command line with the prompt: C:\wamp\bin\php\php5.3.3\php.exe C:\wamp\www\script.php

it dies at the line when it gets to imap_open.

Here is the full code:

$hostname = '{email-host:995/pop3/ssl/novalidate-cert}INBOX';
$username = 'user';
$password = 'password';

$inbox = imap_open($hostname,$username,$password) or die('Cannot connect: ' . imap_last_error());

Any ideas on why it will not work through command prompt.

in php.ini, I have included:

extension=php_imap.dll

extension=php_openssl.dll
  • the php.ini for the command line is different then the one for apache, usually its cli.ini, so likely you don't have the extension enabled in that one... What error do you get when it `dies`, that would be helpful. – ArtisticPhoenix May 26 '16 at 14:10
  • Thanks for the advice. There are two php.ini files, in for wamp, you have to go to the folder: C:\wamp\bin\php\php5.3.3 and edit the php.ini in that folder and that controls the settings for the command prompt. – Seth Knorr May 26 '16 at 14:53

1 Answers1

0

Enable the extension in the cli.ini or php-cli.ini file. Which is a separate config then the one Apache uses.

That's my guess at least... Without knowing what error you get when it dies.

ArtisticPhoenix
  • 21,464
  • 2
  • 24
  • 38