i have three hours trying to connect to imap server with php
but i got that error
Warning: imap_open() [function.imap-open]: Couldn't open stream {213.175.202.118:143}INBOX in /home/user/public_html/imap.php on line 3
my code is
$mbox = imap_open("{ip:143}INBOX", "user", "password");
The mail details above is valid .. i have created it to test it
you can test it easily from your localhost !
i have three hours replacing in imap link
like
ip:143
imap.mydomain.com:143
etc ...
also i am sure i have imap installed on server .. <- i have Cpanel
problem Fixed !
Try (from http://php.net/manual/en/function.imap-open.php); looks ssl related:
<?php
imap_open( "{server.example.com:143/novalidate-cert}INBOX" , 'login' , 'password' );
?>
Related
i'm having a big trouble with the IMAP protocol in PHP.
I tried so many different ways to gather emails from an Gmail account but nothing works for me.
I'm using a WampServer 3.1.0 localhost with every version of every services up to date (except PHP, i'm not using 7.1.9 but the 7.0.23 one)
Here is the code for a Gmail attempt :
<?php
$hostname = '{imap.gmail.com:993/imap/ssl/novalidate-cert}';
$username = 'myemail#gmail.com'; $password = 'mypassword';
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
print_r(imap_errors());
?>
Here are the errors :
Warning: imap_open(): Couldn't open stream
{imap.gmail.com:993/imap/ssl/novalidate-cert} in
C:\wamp64\www\Projet_entreprise\imap_03bis_list.php on line 4
Notice: Unknown: Can't connect to gmail-imap.l.google.com,993: Unknown error (10057) (errflg=1) in Unknown on line 0
Notice: Unknown: Can't connect to gmail-imap.l.google.com,993: Unknown error (10057) (errflg=2) in Unknown on line 0
(My password is only numbers so i tried with and without quotes, same issue).
Even if I activated the IMAP Protocol in the Gmail account settings and the PHP extensions "php_imap" and "php_openssl" are enabled (green validate icon), same issue.
I'd really be grateful if you could try to help me ...
Thank you all for reading and have a good day.
We have a php script to handle bounce mails. Now I have to take care of switching from the PEAR NET/POP3 library to the native-ish php-imap library.
The mailserver listens on a remote server on port 110 without ssl (obviously POP3).
However I am unable to open a connection to that server using the php-imap library using the following code:
imap_open("{example.com:110/pop3/notls}INBOX", $username, $password);
This results in the following errors:
Warning: imap_open(): Couldn't open stream {example.com:110/pop3/notls}INBOX in C:\xampp\htdocs\bounce-processing\info.php on line 1
Notice: Unknown: POP3 connection broken in response (errflg=2) in Unknown on line 0
The following PEAR POP3 implementation still works:
require("Net/POP3.php");
$pop3 = new Net_POP3();
$pop3->connect('example.com', 110)
$pop3->login($username, $password);
What I already tried:
imap_open("{IP-ADDRESS:110/pop3/notls}INBOX", $username, $password);
imap_open("{IP-ADDRESS:110/pop3/notls/user=$username}INBOX", $username, $password);
NOTE: I also tested this on different setups (CentOS / Apache 2.2, Ubuntu 14.04 / nginx, PHP 5.4, PHP 5.5, PHP 5.6, no different outcome.
What can I do? Debugging did not really help me - and that the pear class works freaks me out.
Thanks in advance!
EDIT: php binary is compiled with imap / ssl and the php-imap extension is enabled in the php.ini. If you know another future-proof way to make php talk to a pop3 mailserver, let me know. We don't want to use frameworks such as phpmailer etc.
EDIT2: telnet login works with a success rate of 40%. I was able to successfully log in 4 out of 10 times with correct credentials.
Output of the CAPA command:
CAPA
+OK Here's what I can do:
STLS
TOP
USER
LOGIN-DELAY 10
PIPELINING
UIDL
IMPLEMENTATION Courier Mail Server
.
I don't know if thats important, but the mailserver is in fact hosted by a dedicated server housing and hosting company.
EDIT3: Trying to connect via
{IP_ADDRESS:110/pop3}
returns the following errors:
Warning: imap_open(): Couldn't open stream {IP_ADDRESS:110/pop3} in C:\xampp\htdocs\bounce-processing\index.php on line 12
Notice: Unknown: Certificate failure for IP_ADDRESS: Server name does not match certificate.
Appending the flag novalidate-cert leads to a timeout.
I have enabled OpenSSL and IMAP functions from my php.ini file and phpinfo() confirms it.
By using the code below i can connect to a Hotmail account but not to a Gmail account.(of course i change the $connect_to to point to Hotmail.)
$connect_to = '{imap.gmail.com:993/imap/ssl}INBOX';
$connection = imap_open($connect_to, $user, $password)
or die("Can't connect to '$connect_to': " . imap_last_error());
imap_close($connection);
The returned error is
Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in /opt/lampp/htdocs/webmail_client_practise/index.php on line 6
Can't connect to '{imap.gmail.com:993/imap/ssl}INBOX': Certificate failure for imap.gmail.com: unable to get local issuer certificate: /C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
Notice: Unknown: Certificate failure for imap.gmail.com: unable to get local issuer certificate: /C=US/O=GeoTrust Inc./CN=GeoTrust Global CA (errflg=2) in Unknown on line 0
Unfortunately i cannot find a complete tutorial of how to use the IMAP functions.
Any ideas, solutions or suggestions will be helpful.
UPDATE:
After searching for my problem on the Internet, i did not found a solution that solves my problem completely. Although if
1) I use the insecure $connect_to = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
2)And allow gmail to be accessed by less secured apps,
solves my problem for now.
Please check this https://support.google.com/accounts/answer/6010255?hl=en
If you get blocked, this can be because google sees a login from a new device.
Go to your google account and check
https://myaccount.google.com/device-activity
and let them know the 'Unknown device is ok to use'.
First check your date and time settings on your server are correct.
Alternatively try:
$connect_to = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX',
This will stop it from trying to validate certificate.
I will probably get downvotes from people telling me this is bad practice as this leaves you open to Man in the Middle attacks. Which is true.
I try to open an IMAP connection via PHP
imap_open ("{localhost:993/ssl}", "username", "pwd")
ok, this doesn't work as expected, cause I'm using a self-signed cert. But at least I got an error:
Warning .... Couldn't open stream
So I try
imap_open ("{localhost:993/ssl/novalidate-cert}", "username", "pwd")
And then: nothing - white page - no errors or warning, no errors in serverlog.
The mailserver is correctly configured - it's no problem to connect via thunderbird or outlook with enabled ssl-encryption on this port.
I also tried to connect with imap_open and ssl and novalidate-cert to 127.0.0.1, to the hostname, to the IP-address -none of these trials works as soon as I add the novalidate-cert parameter. I've no idea why.
I've also checked php_info: SSL is enabled for IMAP and also openssl is active.
If I connect without SSL everything works fine.
Thank you very much for your help
Try to add imap before ssl ,
it should be like :
imap_open ("{localhost:993/imap/ssl/novalidate-cert}", "username", "pwd")
Try
imap_open ("{localhost:993/imap/ssl/novalidate-cert}", "username", "pwd")
..that worked for me.
I'm trying to access my icloud mailbox from my website. The code I'm using works fine with gmail, but when I try to connect to my iCloud account i get this error:
Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.mail.me.com:993/ssl/imap} in /hp/bd/ab/lq/www/rechner/Messages/MailAusgabe.php on line 6
and this is my code:
$mbox = imap_open("{imap.mail.me.com:993/ssl/imap}", "myemail#me.com", "mypassword");
and this aswell:
$mbox = imap_open("{imap.mail.me.com:993/ssl/imap}INBOX", "myemail#me.com", "mypassword");
I've already changed my password and tried some other accounts, but without success.
Try replacing this: "{imap.mail.me.com:993/ssl/imap}" by this: {imap.mail.me.com:993/imap/ssl}