How to Install imap extension in PHP on Linux?
Last Updated :
31 Jan, 2022
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:
- Access: Whenever you are accessing mails using IMAP, you are directly accessing mails from email servers. Hence, you can manage and access mails and mail folders from any computer or mobile phone.
- IMAP uses fetch technology, so when a new email arrives email client automatically fetches new mails at specified intervals.
- Server-side searches: IMAP4 provides a feature for the client to ping the server to search for the mail using various searching criteria.
Disadvantages of IMAP:
- IMAP4 clients need to maintain a TCP/IP connection with the IMAP server to receive the notification of the new mails.
- Unless mail storage and server search algorithms are carefully implemented, a customer may potentially consume large quantities of server resources when searching for massive mailboxes.
- It can be complex to maintain due to which some host does not support the protocol. It also required the drive space of the host to perform the operation.
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.
Similar Reads
How to Install IMAP Extension in PHP on MacOS? Imap stands for Internet Message Access Protocol, It is a protocol used by email clients to retrieve email messages from mail servers, It is an application layer protocol in the OSI model. Imap allows us to store our messages on servers so that they can be accessed from multiple devices, whereas POP
4 min read
How to Install imap extension in PHP on Windows? IMAP stands for Internet Message Access Protocol. It is an application layer protocol. PHP-IMAP is used to efficiently access messages from the IMAP server. IMAP stores email on the server and can download on-demand. To access the IMAP server we have to use PHP IMAP extension, now using this extensi
2 min read
How to Install Imagick for PHP in Linux? Imagick is a PHP ImageMagick extension. It is a native PHP extension to create and modify images using the ImageMagick API. It is used to read, write, and convert the images in any formats including, EXR, GIF, JPEG, PDF, PNG, PhotoCD, TIFF, etc. In this article, we will learn how to install Imagick
2 min read
How to Install PHP intl extension in Ubuntu? The Internationalisation (Intl) extension is a wrapper for the ICU library, a collection of C/C++ and Java libraries that provide Unicode and Globalisation support for software applications. It tends to closely follow ICU APIs so that people having experience working with ICU in either C/C++ or Java
2 min read
How to Install Imapclient in Python on Linux? IMAPClient is a Python-based, easy-to-use, and comprehensive IMAP client library. Although IMAPClient makes use of the imaplib module from the Python standard library, it has its own API. IMAPClient officially supports Python versions 2.7 and 3.4 through 3.9. So, in this article, we'll learn how to
1 min read