0

I'm trying to install/enable IMAP on an elastic beanstalk environment. I got the IMAP module installed as shown by the command below (when executed by SSHing into the ec2 instance).

$ php -m | grep imap
PHP Warning:  Module 'imap' already loaded in Unknown on line 0 imap

Not sure if the warning has anything to do with the error I'm seeing, but either way, IMAP is being loaded.

However when I call imap_open() in my PHP code, I get this error:

PHP Fatal error: Uncaught Error: Call to undefined function imap_open()

I looked at this answer, but it's almost 10 years old, and looking at other questions (here and here) this isn't as simple as adding a line to a php.ini file on Linux.

msg
  • 7,863
  • 3
  • 14
  • 33
Kevin Rock
  • 249
  • 3
  • 11
  • `php -m` does not tell you if you edited the correct php.ini (yes, there's more than one / and the usual: some SAPIs require a server restart, obviously). – mario Jun 20 '19 at 18:52
  • 1
    after installation did you restart your server httpd or apache2 service? first restart your server and check. – Priyanka Sankhala Jun 20 '19 at 18:53
  • I am not sure if you could send emails from amazon-ec2 instance at all... Probably you have to use their ("Amazon SES") mail service provider or similar. – YanDatsiuk Jun 20 '19 at 19:01
  • @YanDatsiuk This is for retrieving emails. – Kevin Rock Jun 20 '19 at 19:05
  • Hi @Kevin Rock. Sorry - you are right. Could you try to output enabled modules from your script. You could try, for example: die(phpinfo()); Just to make sure, that you are viewing information from php that is used by web server... Because when you are running "php -m" - it is a list of enabled modules in for CLI. Then you will now if imap is enabled or not. – YanDatsiuk Jun 20 '19 at 19:13
  • @YanDatsiuk, thanks for responding. As I said in my answer, I was able to enable by logging in as root and restarting the server. I checked the logs and I'm getting a "imap_open(): Couldn't open stream" error, so it looks like imap is enabled and running fine. – Kevin Rock Jun 20 '19 at 19:18
  • @KevinRock If you are sure, that extension is enabled then could you check if network ports 143 or probably 993 are opened? – YanDatsiuk Jun 20 '19 at 19:25
  • @YanDatsiuk, Looks like the ports are open on the ec2 instance. (I'm specifically using 993 to connect). So I'm going to have to dig into why the IMAP stream isn't being opened. – Kevin Rock Jun 20 '19 at 19:39
  • PD of [Do I need to restart Apache after changing the php.ini file?](//stackoverflow.com/q/12892331) / [Changes to upload\_max\_filesize in Ubuntu php.ini will not take effect](//stackoverflow.com/q/14327409) / … – mario Jun 20 '19 at 20:19

1 Answers1

0

As per @Priyanka Sankhala's comment, I restarted the httpd service, and that worked. I thought I had tried that before, but apparently I had only tried as a non root user, so I couldn't restart the service successfully. Sudo'ing and restarting the service allow IMAP to work.

Kevin Rock
  • 249
  • 3
  • 11