8

How can one install imap for php in ubuntu for php7.1 preferably in the terminal.

There's some info on this on the php.net manual but it's a bit dated.

It talks about the c-client library and restarting apache afterwards etc

I'm still pretty new with linux

9
  • 1
    As always on Linux systems: use your distributions software management system which is way more convenience and safer than doing a manual install yourself.
    – arkascha
    Commented Jul 19, 2017 at 16:50
  • I was hoping to use the terminal. I've made a script that uses the imap() functions and have been running them in an apache environment with XAMPP on windows by changing the php.ini file to allow for imap. When running the same script in a linux (Ubuntu) environment I had an error in the browser and realized I hadn't at all installed imap. the software manager is great but isn't addressing my specific goal because I get multiple packages showing after searching for imap and I have no idea what they do.
    – grendeld
    Commented Jul 19, 2017 at 16:54
  • You can use the software management on the command line. Just read an introduction to it. And actually it gives a description for each package telling you what it contains...
    – arkascha
    Commented Jul 19, 2017 at 16:59
  • OH. That sounds cool. Thanks. I'll play with it.
    – grendeld
    Commented Jul 19, 2017 at 17:03
  • 2
    You mean you never even tried before asking? Hmmmmm
    – arkascha
    Commented Jul 19, 2017 at 17:03

2 Answers 2

22

As long as it is part of the php repo you are using, this will be the package you are looking for.

sudo apt install php7.1-imap
5
  • not ...(apt-get)...?, also I'm using 7.1.6 if that makes a difference
    – grendeld
    Commented Jul 19, 2017 at 17:00
  • depends on version of ubuntu. Newer versions renamed apt-get to just apt. But apt-get will also work. This is also assuming you used the package management to install php7.1 Commented Jul 19, 2017 at 17:02
  • I'm using the ppa:ondrej/php repo.
    – grendeld
    Commented Jul 19, 2017 at 17:29
  • Great repo. It has that package from what I recall, so you should be able to install it with apt, or apt-get, depending on ubuntu version. Commented Jul 19, 2017 at 17:38
  • 4
    Works for php 7.2 with sudo apt-get install php7.2-imap Commented Dec 12, 2018 at 0:27
3

You can install IMAP by following ways.

Step1: sudo apt-get install php7.1-imap

Step2: sudo phpenmod imap

Step3: php -m. Find out imap module

Step4: Run below command to confirm imap is install. 1. php -i | grep -i imap 2. dpkg -l | grep php7.1-imap

Step5: check phpinfo()enter image description here

check imap is showing or not.

After enabling a module, you have to restart your pc. If a module is still not displayed in phpinfo(), please check on the next day.

Not the answer you're looking for? Browse other questions tagged or ask your own question.