Can't connect to IMAP with PHP - php

i'm trying to connect php with an imap server but i'm getting this error:
Warning: imap_open() [function.imap-open]: Couldn't open stream
{mail.XXX.it:143/imap/notls/norsh}INBOX Array ( [0] => SECURITY
PROBLEM: insecure server advertised AUTH=PLAIN [1] => Can not
authenticate to IMAP server: AUTHENTICATE mechanism not supported,
mate ) Cannot connect: 1
When trying to connect mail.XXX.it:143/imap/notls/norsh
And this error:
Warning: imap_open() [function.imap-open]: Couldn't open stream
{mail.XXX.it:143/imap/secure/notls/norsh}INBOX Array ( [0] => Can't do
secure authentication with this server ) Cannot connect: 1
When trying to connect mail.XXX.it:143/imap/secure/notls/norsh
How can i get around this?
(Hosting has no SSL security)
Thanks

Have you tried checking your ssl certs? If the server has a self-signed cert it might cause
php's imap library to throw a configurable error (possibly what you are getting). Furthermore the imap library is installed as a package, sometime separately, you might want to check your configurations for this lib.
Tell me what you think and a curl -v basic auth attempt readout might be helpful,
Cheers

Related

imap_open(): Couldn't open stream (imap ssl)

I'm trying to read emails from imap mail with the php library ddeboer/imap .
I've created a subdomain like this: abm.mydomain.be . The IMAP extension wasn't installed so I asked the server administrator to install it. The function imap_open now exists. But now I'm getting the following error:
AuthenticationFailedException in Server.php line 76:
Authentication failed for user abm#mydomain.be with error imap_open(): Couldn't open stream {mail.mydomain.be:993/imap/ssl/validate-cert}
The user and passwords are correctly (100% sure of that). When I check phpinfo I see the following with imap:
Does anyone knows what I'm doing wrong?

PEAR/POP3 connects to mailserver, php-imap doesn't

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.

Execute Apple Push Notification Server (PHP) from Android Device using "PHP for Android"

I recently downloaded and installed "PHP for Android." I created a .php file that utilizes an SSL connection with port 2195. I followed a guide for writing a php server that sends push notifications to Apple's APNS, and SUCCESSfully ran it on my Mac. When I put both the .php and the .pem onto my Android phone in the same folder and tried to run it with the same WIFI connection, I get the following error message:
Error:14094410:SSL routines:func(148):reason(1040) in /mnt/sdcard/sl4a/scripts/lot.php on line 19
Warning: stream_socket_client(): Failed to enable crypto in /mnt/sdcard/sl4a/scripts/lot.php on line 19
Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in /mnt/sdcard/sl4a/scripts/lot.php on line 19
Does anyone have any ideas of how I can fix this?
THANKS!
I had the SSL error on my Windows desktop, with a PHP script that accessed a HTTPS resource.
The solution was to enable the openssl extension. So maybe it's the same kind of problem you have here, something related to opensll on Php for Android.
I'm not sure how to fix it, but Google has it's own push notification framework. There is an example here: http://code.google.com/android/c2dm/
Edit to Answer:
I think that most likely the problem has to do with the certificates needed to make the call over SSL. It is possible that the PHP for Android app does not have permissions to access security certificates you need.

Zend Soap Client error: Failed to enable crypto

Hey guys, I'm using the Zend Soap Client library to consume a webservice, like this:
$wsdl = "path_to_wsdl_file";
$client = new Zend_Soap_Client($wsdl);
$client->nfeRecepcaoLote();
And I'm receiving the following errors:
Warning (2): SoapClient::__doRequest() [soapclient.--dorequest]: Failed to enable crypto [CORE/vendors/plugins/nfe/vendors/Zend/Soap/Client.php, line 987]
Warning (2):SoapClient::__doRequest() [soapclient.--dorequest]: connect() failed: Unspecified error [CORE/vendors/plugins/nfe/vendors/Zend/Soap/Client.php, line 987
Does anyone know what it can possibly be? The host of the webservice is this:
https://homologacao.nfe.ms.gov.br/homologacao/services/NfeRecepcao
and I'm using PHP 5.2.6 and Ubuntu 9.10.
Best regards,
Zé
Looks like is because you are trying to access a SSL service with a self-signed certificate. To allow that you need to authorize it. Look Zend Soap Client documentation on connection adapters.

having issue with fsockopen while sending mail with swiftmailer

I was playing around the new swiftmailer 4.0.4 using my zend studio embbeded apache server where i can send successfully emails through gmail smtp.
Now that it's was fine and that i decided to use it in real project and this time along using xampp 1.6.8.any time i run the same function there is this error
Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\xampp\htdocs\project\includes\swift\classes\Swift\Transport\StreamBuffer.php on line 243
i've tried to enable ssl from xampp index file it has accepter the certificate but still my error won't disapear.I'm really concerned about this.Can anyone share his opinion or experience? thanks for reading!
The problem is that you don't have the ssl transport installed for php. Different systems do this in different ways, so I don't know how yours would work.
You can run a quick php app to verify this:
<?php
print_r(stream_get_transports());
Mine returns:
Array
(
[0] => tcp
[1] => udp
[2] => unix
[3] => udg
[4] => ssl
[5] => sslv3
[6] => sslv2
[7] => tls
)
If ssl and tls are not there, then your php installation does not have support for them and you need to find a way to fix that.
i think for some reason it started working.i'm not sure about what happened,i reinstall xampp and didn't see the problem anymore.weird.

Categories