Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Call to undefined function imap_open()

602 views
Skip to first unread message

Mark5320

unread,
Sep 3, 2022, 4:34:31 AM9/3/22
to
$ php -r 'imap_open();'
PHP Fatal error: Uncaught Error: Call to undefined function imap_open()
in Command line code:1

I know, you have to install the appropriate extension (sudo apt install
SOMETHING).
But there is a special command (for Ubuntu 22.04.1) to establish
precisely (without going to google) what extension (package) should we
install?
For example

$ php-owner-package imap_open
imap_open() function it's included into package SOMETHING

J.O. Aho

unread,
Sep 3, 2022, 5:46:07 AM9/3/22
to
On 03/09/2022 10.34, Mark5320 wrote:
> $ php -r 'imap_open();'
> PHP Fatal error:  Uncaught Error: Call to undefined function imap_open()
> in Command line code:1
>
> I know, you have to install the appropriate extension (sudo apt install
> SOMETHING).

sudo apt install php-imap

> But there is a special command (for Ubuntu 22.04.1) to establish
> precisely (without going to google) what extension (package) should we
> install?
> For example
>
> $ php-owner-package imap_open
> imap_open() function it's included into package SOMETHING

No there ain't a tool to tell you to which extension a function may
belong to.

As the extensions tend to have functions with the extension name, so
that the common part of the functions name and search for it with

apt-cache search imap | grep php

and you would have a good chance to see the extension as part of the
result, sure not all extensions do have this the uniformity in function
names and not all are included in the official ubuntu/debian repository.

--
//Aho

Mark5320

unread,
Sep 3, 2022, 7:02:05 AM9/3/22
to
Il 03/09/22 11:45, J.O. Aho ha scritto:
>> $ php -r 'imap_open();'
>> PHP Fatal error:  Uncaught Error: Call to undefined function
>> imap_open() in Command line code:1
>>
>> I know, you have to install the appropriate extension (sudo apt
>> install SOMETHING).
>
> sudo apt install php-imap

Where is the official documentation that says you need to install this
extension?
How did you come to this conclusion?

J.O. Aho

unread,
Sep 3, 2022, 7:30:38 AM9/3/22
to
The official php documentation mentions these in the build instructions,
but talking about which features you need, you need to give different
build options, each of those build options are generally made into a php
extending package in different Linux distributions.

The Unix-philosophy has an element of having only the bar minimum
installed that makes it possible to do what you need to do, so you want
to connect to a postgresql database, then you don't need all the stuff
to connect to mysql nor mssql databases.

This also has a security benefit, the attack vector becomes smaller the
less extensions you have installed, as you know from time to time there
are vulnerabilities found and say there would be a xml related
vulnerability in php version you are using, but if you don't have the
xml support built in nor an xml extension, then you not affected by that
vulnerability, but if you have xml support then you are vulnerable.

See the positive thing, all you need to do is use apt to install the
extensions, while those with microsoft windows has to search on the net
to find the extension built for the same version of php as you are using
and you won't be sure if the one you find has a backdoor built into it
or not.


> How did you come to this conclusion?

Been around Linux for a long time and even been building packages once i
the time.

--
//Aho


Mark5320

unread,
Sep 3, 2022, 9:00:37 AM9/3/22
to
Il 03/09/22 13:30, J.O. Aho ha scritto:
>
> The official php documentation mentions these in the build instructions,
> but talking about which features you need, you need to give different
> build options, each of those build options are generally made into a php
> extending package in different Linux distributions.
>
> The Unix-philosophy has an element of having only the bar minimum
> installed that makes it possible to do what you need to do, so you want
> to connect to a postgresql database, then you don't need all the stuff
> to connect to mysql nor mssql databases.
>
> This also has a security benefit, the attack vector becomes smaller the
> less extensions you have  installed, as you know from time to time there
> are vulnerabilities found and say there would be a xml related
> vulnerability in php version you are using, but if you don't have the
> xml support built in nor an xml extension, then you not affected by that
> vulnerability, but if you have xml support then you are vulnerable.
>
> See the positive thing, all you need to do is use apt to install the
> extensions, while those with microsoft windows has to search on the net
> to find the extension built for the same version of php as you are using
> and you won't be sure if the one you find has a backdoor built into it
> or not.
>
>
>> How did you come to this conclusion?
>
> Been around Linux for a long time and even been building packages once i
> the time.

thanks from info

Mark5320

unread,
Sep 3, 2022, 9:05:57 AM9/3/22
to
Il 03/09/22 15:00, Mark5320 ha scritto:
>
> thanks from info

by the way, what are the differences between the various versions found

~$ apt search imap | grep php



WARNING: apt does not have a stable CLI interface. Use with caution in
scripts.



php-imap/jammy,jammy 2:8.1+92ubuntu1 all

php-net-imap/jammy,jammy 1:1.1.3-2.1 all

php8.1-imap/jammy-updates 8.1.2-1ubuntu2.3 amd64


J.O. Aho

unread,
Sep 3, 2022, 11:30:34 AM9/3/22
to

On 03/09/2022 15.05, Mark5320 wrote:
> Il 03/09/22 15:00, Mark5320 ha scritto:
>>
>> thanks from info
>
> by the way, what are the differences between the various versions found

I'm not a Ubuntu user, so not fully aware of everything,
but I think the php version is a php 7.x while php8.1 is as you may have
guessed php 8.1.x

> php-imap/jammy,jammy 2:8.1+92ubuntu1 all
> php8.1-imap/jammy-updates 8.1.2-1ubuntu2.3 amd64

This I think is the php's default imap implementation for php7 and php8.1


> php-net-imap/jammy,jammy 1:1.1.3-2.1 all

This is an optional imap implementation built on top of PEAR's Net_Socket.
I would recommend against this one, there been no development since 2014.

More about PEAR: https://pear.php.net

--

//Aho

John-Paul Stewart

unread,
Sep 3, 2022, 3:09:08 PM9/3/22
to
On 2022-09-03 09:05, Mark5320 wrote:
>
> by the way, what are the differences between the various versions found
>
> ~$ apt search imap | grep php
>
>
>
> WARNING: apt does not have a stable CLI interface. Use with caution in
> scripts.
>
>
>
> php-imap/jammy,jammy 2:8.1+92ubuntu1 all
>
> php-net-imap/jammy,jammy 1:1.1.3-2.1 all
>
> php8.1-imap/jammy-updates 8.1.2-1ubuntu2.3 amd64

In the Debian/Ubuntu packaging, php-imap is a generic package that
automatically pulls in whatever the current version is. In your case,
that's php8.1-imap. The result is that if you install php-imap today,
when 8.2 or 9.0 comes along the distribution will automatically upgrade
you to that version. (The php8.1-imap package will still be installed
as a dependency of php-imap, but it will flagged as such in the package
database, thus subject to be upgraded.)

Conversely, if you manually install php8.1-imap today (so that is marked
as "manual" in the package database), then when the next version comes
along the distro will NOT automatically upgrade it. If you want the
next version, you'll have to install that manually when you're ready.

So, install the generic one if you want automatic version updates or
install the versioned one if you have a specific need to stay on that
version.

Mark5320

unread,
Sep 5, 2022, 5:23:14 AM9/5/22
to
Il 03/09/22 21:08, John-Paul Stewart ha scritto:
> ...

thanks

Kristjan Robam

unread,
Sep 9, 2022, 7:00:19 AM9/9/22
to
Implement this then.

Arno Welzel

unread,
Sep 9, 2022, 10:30:37 AM9/9/22
to
Kristjan Robam, 2022-09-09 13:00:

> Implement this then.
>
> Mark5320 kirjutas Laupäev, 3. september 2022 kl 11:34:31 UTC+3:
>> $ php -r 'imap_open();'
>> PHP Fatal error: Uncaught Error: Call to undefined function imap_open()
>> in Command line code:1
[...]


This is not a helpful answer.

1) Please put your response *below* a quote - text is read from top to
bottom. This is Usenet not e-mail.

2) imap_open() is not to be implemented but provided by an PHP extension
which has to be enabled:

<https://www.php.net/manual/en/function.imap-open.php>

<https://www.php.net/manual/en/imap.setup.php>


--
Arno Welzel
https://arnowelzel.de
0 new messages