Z
Z
Zimaell2019-07-15 10:59:44
PHP
Zimaell, 2019-07-15 10:59:44

How to get imap gmail php emails?

Trying a simple PHP example

$imap = imap_open('{imap.gmail.com:993/imap/ssl}INBOX', $username, $password);
$emails = imap_search($imap, 'ALL');
if($emails) echo count($emails);
imap_close($inbox);

imap in php is installed but gives the following error
PHP Warning:  imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX
PHP Warning:  imap_search() expects parameter 1 to be resource, bool given in 
PHP Notice:  Undefined variable: inbox in 
PHP Warning:  imap_close() expects parameter 1 to be resource, null given in 
PHP Notice:  Unknown: Retrying PLAIN authentication after [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0
PHP Notice:  Unknown: Retrying PLAIN authentication after [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0
PHP Notice:  Unknown: Can not authenticate to IMAP server: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=2) in Unknown on line 0

after reading on the forums they offer to check via telnet
telnet imap.gmail.com:993
for what in response to me
telnet: could not resolve imap.gmail.com:993/telnet: Name or service not known

that is, as I understand it, telnet is not installed, I install it
sudo apt install telnet
Reading package lists... Done
Building dependency tree
Reading state information... Done
telnet is already the newest version (0.17-41).
The following package was automatically installed and is no longer required:
  libzip5
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 24 not upgraded.

that is, it is still installed ...
In general, I got confused, tell me who knows what to do on this issue ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2019-07-15
@Zimaell

Good afternoon.
How to install imap ubuntu php 7.2?
See the postscript to the answer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question