Fatal error Call to undefined function imap open in PHP

0 votes

I am trying to access my gmail account through my localhost. However, I am getting the response:

Fatal error: Call to undefined function imap_open()

This is my code:

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'myid@gmail.com';
$password = 'mypassword';

/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' .imap_last_error());
Oct 29, 2020 in PHP by kartik
• 37,520 points
5,636 views

1 answer to this question.

0 votes

Hello @kartik,

In Ubuntu for install imap use

sudo apt-get install php-imap

Ubuntu 14.04 and above use

sudo apt-get install php5-imap

And imap by default not enabled by PHP so use this command to enable imap extension

sudo php5enmod imap

Then restart your Apache

sudo service apache2 restart

Hope it helps!!

answered Oct 29, 2020 by Niroj
• 82,840 points

Related Questions In PHP

0 votes
0 answers
0 votes
1 answer

Fatal error: Call to undefined function mysql_connect()

Hello @kartik, You upgraded to PHP 7, and ...READ MORE

answered Nov 23, 2020 in PHP by Niroj
• 82,840 points
3,526 views
0 votes
1 answer

How to auto call function in php for every other function call?

Hii, Your best bet is the magic method __call, ...READ MORE

answered Oct 30, 2020 in PHP by Niroj
• 82,840 points
6,554 views
0 votes
1 answer

Error: Call to undefined function money_format()

Hello @kartik, If you are using windows based ...READ MORE

answered Nov 16, 2020 in PHP by Niroj
• 82,840 points
2,783 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
23,012 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
2,994 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
2,918 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
44,690 views
0 votes
1 answer

Fatal error: Call to undefined function ImageCreate() in /home/t1g01/phplot.php on line 248

Hello @kartik, Your server most like does not ...READ MORE

answered Nov 18, 2020 in PHP by Niroj
• 82,840 points
6,267 views
0 votes
1 answer

Fatal error: Call to undefined function socket_create()

Hello @kartik, For a typical XAMPP install on ...READ MORE

answered Nov 3, 2020 in PHP by Niroj
• 82,840 points
6,715 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP