Open In App

How to Install imap extension in PHP on Linux?

The Internet Message Access Protocol (IMAP) is an application layer protocol that allows a client to efficiently access emails from anywhere. It stores email on the server and can download on-demand. It is like an intermediary between client and email servers. It was designed by Mark Crispin in 1986 as a remote access mailbox protocol and the current version of IMAP is IMAP4.

Advantages of IMAP:



Disadvantages of IMAP:

Verify PHP IMAP installation on Linux

To verify your installation, follow the following steps:



Step 1: Open a terminal and change your directory to the webroot folder using the following command:

cd /var/www/html/

Step 2: Create a file with any name with the extension .php using any editor. I am using nano here. Also, avoid using “phpinfo” as a file name.

sudo nano whatever.php

Step 3: Write the following code in the file “whatever.php”

<?php

phpinfo();

?>

Step 4: Hit Ctrl+x, then respond with “Y” for yes, then press the ENTER button. 

Step 5: Run the command ifconfig in the terminal and copy the URL.

Step 6: Open a Web browser and paste the URL along with “whatever.php” at the end. URL should look like this

http://your_URL/whatever.php 

Look for the file named “/etc/php/7.4/apache2/conf.d/20-imap.ini”. If it is present IMAP extension is already installed. Otherwise, follow the steps below.

Installing PHP IMAP on Linux

To install the IMAP extension, perform the following steps:

Step 1: Enter the following commands in the terminal to install the IMAP extension for any PHP version on Linux

sudo apt install php-imap

Step 2: Enable PHP IMAP extension using the following command:

sudo phpenmod imap           

Step 3: Restart the Apache server using the following command:

sudo systemctl restart apache2 

Step 4: Verify IMAP installation again.

http://your_URL/whatever.php 

Hence, this is how we install the PHP IMAP extension in Linux.

Article Tags :