imap google with php: couldn't open stream - php

I'm trying to get emails through a PHP script:
$mbox = imap_open("{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX", "username#gmail.com", "password");
But I'm constantly getting this error:
Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX
IMap is enabled on my Google Account.
From the server, I tried nmap -p 993 imap.gmail.com and it return that there is imap service under this address.
regards

In my case, this error is caused by the outbound proxy blocking access to port 993.

Related

unable to connect to hostgator using imap library in codeingiter

I tried to get emails from gmail server using imap library
$this->conn = imap_open("{".$this->server.":993/imap/ssl}INBOX",$this->user,$this->pass);
I got error like:
Message: imap_open(): Couldn't open stream {mail.server.com:993/ssl}
It was start working after I unchecked the less secure apps option from my gmail account and then got emails.
but when i used to get emails from hostgator server i got same error
Message: imap_open(): Couldn't open stream {mail.server.com:993/ssl}
Message: Unknown: Can not authenticate to IMAP server: [AUTHENTICATIONFAILED] Authentication failed. (errflg=2)
Message: Unknown: Retrying PLAIN authentication after [AUTHENTICATIONFAILED] Authentication failed. (errflg=1)
Like gmail server is their any option that i should check or uncheck in hostgator server. or any other method I should used?

PHP imap_open(): Couldn't open stream to gmail

I'm getting this messages when I tried to use php-imap to retrieve emails from server using IMAP protocol. I started with gmail accounts. But when I tried to connect using imap_open() I get the following messages:
Warning: imap_open(): Couldn't open stream {imap.gmail.com/imap/ssl:993}INBOX in \path\to\file\imap.php on line 6
or
Warning: imap_open(): Couldn't open stream {imap.gmail.com/imap/ssl/novalidate-cert:993}INBOX in \path\to\file\imap.php on line 6
depending if I use or not novalidate-cert
I found some related question, but not the solution
imap_open(): Couldn't open stream
Getting Error like imap_open(): Couldn't open stream in server
Connecting to Gmail IMAP PHP "Couldn't open stream"
Is it possible connect to email using the imap php extension?
If, Yes. How can I solved this message?
If, No. Which alternative for received email using PHP could be possible?
Try imap.gmail.com:993/imap/ssl. Port number comes after the domain name and befor the URI path.

php imap_open giving issues connecting

I am having some issues with imap_open.
This is the error I am getting:
Message: imap_open(): Couldn't open stream
{imap-mail.outlook.com:993/imap/ssl/novalidate-cert}INBOX
No matter if its imap using ssl on port 993 or pop ssl on port 995, I am getting the same error.
Message:
Unknown: Can't open mailbox
{imap-mail.outlook.com:993/imap/ssl/novalidate-cert}INBOX: invalid
remote specification (errflg=2)
I have the following setup:
Mac OSX Yosemite
Mamp Pro running PHP 5.6.10
Here is what I've done to troubleshoot:
I have apple mail setup to check my gmail account using imap ssl on port 993. I will assume if apple mail can retrieve mail, the port is open.
I went to Security and Privacy and did a PORT SCAN... 993 and 995 were not open... strange.
I do not have Mac Firewall enabled.
When using non ssl, on port 110 pop, this appears to be working fine.
Can anyone assist to see what may be the cause.
Check phpinfo() to see if php is complied --with-imap-ssl
http://www.bartvanasselt.nl/mamp-pro-using-imap-with-ssl/
Also can try tunneling:
Workaround for PHP IMAP functions? Trying to work with incoming email on localhost using XAMPP

How do you unblock the 993 port if your firewall settings is blocking it?

I am trying to retrieve my emails from Gmail using php.
for writing the host name, this is my code:
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
I am getting this error:
Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in /home1/mtc/public_html/mtcerp/emailparser/email.php on line 10
Cannot connect to Gmail: Can not authenticate to IMAP server: [CLOSED] IMAP connection broken (authenticate)
I wanted to solve this by unblocking the 993 port as may be my firewall settings is blocking it.
How do i unblock this?
You can find the answer here which is already asked on Stackoverflow.
Make sure that the mailbox you are trying to connect is IMAP.
PS. It doesn't look like firewall issue to me
I was able to solve the problem. It is not the firewall problem or the mailbox problem. You just have to write imap.googlemail.com instead of imap.gmail.com in the hostname:
$hostname = '{imap.googlemail.com:993/imap/ssl}INBOX';

PHP imap_open not working

I'm getting an error:
Warning: imap_open() [function.imap-open]: Couldn't open stream {pop3.live.com:995/pop3/ssl/novalidate-cert}INBOX in /home/.../imap.php on line 3
when using code:
$mbox = imap_open('{pop3.live.com:995/pop3/ssl/novalidate-cert}INBOX', '<user>', '<pass>');
Your URL has pop3 for a sub-domain. Are you sure that IMAP is available (ports 143 or 993 open)?
Doing a quick search, it looks like imap has to be enabled on your live.com account. Are you able to IMAP to the server using a standard mail client, like Thunderbird?
Also, you are pointing to pop3.live.com on port 995, which is a POP3 port, not an IMAP port.
In my case it was {domain:110/pop3/novalidate-cert}INBOX that helped me in fixing both the CLOSED IMAP connection broken (server response) and Certificate failure for domain.
Confirm your ports and also whether you have ssl enabled using
openssl s_client -crlf -connect your-domain-name:port-number

Categories