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
Related
I developed a simple code, with the php language, to connect to my email and count the number of emails received, using the local Window 10 server.
<?php
// server IMAP per la connessione
$server = "{imap.gmail.com:993/ssl/novalidate-cert}";
// account Gmail
$login = 'login#gmail.com';
// password per l'accesso a Gmail
$password = 'password';
// connessione IMAP ad un account Gmail
$connessione = imap_open($server, $login, $password);
$conteggio = imap_num_msg($connessione);
echo $conteggio."<br>";
By enabling the IMAP protocol on Gmail and enabling access to less secure apps, the code does
not give any kind of error.
The problem arises when I try to execute this code into a Centos 7 server machine.
I installed the IMAP protocol compatible with my PHP 7.3 version, using this command line: yum --enablerepo=centos-sclo-sclo-testing install sclo-php73-php-imapservice imapd restart.
Once the package is successfully downloaded, I restart the server machine and go check on
<?php
phpinfo();
?>
and notice that the IMAP is enabled.
imap
IMAP c-Client Version 2007f
SSL Support enabled
Kerberos Support enabled
After this check, if I try to run my initial code, this error message appears to me on output: warning: imap_open(): couldn’t open stream {imap.gmail.com:993/ssl/novalidate-cert} even though i have enabled imap and by actvaing.
PS. the password and login are correct.
The issue doesn't seem to be PHP related, but connection related, especially if the script works on a different machine.
There are two things you need to check.
Can you outbound connect on port 993 (is it open for OUT connections). You can try telnet to check that and if it doesn't work verify your Linux Firewall settings.
Do you have SELinux enabled and if you do did you check your audit log for AVC denials? It you have issues you may need to enable your httpd_can_network_connect or even do an audit2allow as the port might be non-standard. Be careful what you are doing as you can disrupt security on your server.
I am designing a website for a company that uses a Windows hosting platform through Peer1 Hosting. I am trying to get a php contact form (that works correctly on a linux server) to work properly. I had Peer1 install php on the server but the emails are still not being sent (there is no error but the emails are not being delivered).
From what I understand, the SMTP sendmail functions need to be configured in the php.ini but I don't believe this is something I have access to and Peer1 won't offer support for php because it is an unsupported installation. Please help!
EDIT: I am trying this as a small test... I am not sure about the 'smpt.domain.com' because some things say it should be 'mail.domain.com' or just the server name but I only have an IP address.
<?php
ini_set('SMTP', 'smtp.domain.com');
ini_set('smtp_port', '25');
ini_set('sendmail_from', 'example#domain.com');
if(mail('me#gmail.com','TEST CONTACT FORM','TEST MESSAGE')){
echo('ok');
}
else{
echo('not ok');
}
?>
This is the error I received when adding error reporting:
Warning: mail(): Failed to connect to mailserver at "smtp.theinspros.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\HTTP\Old Web\version.php on line 9
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'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
i wa trying to do mail with php codeigner, but unfortunately its not working. the error which i got was the following; somebody please help me..
A PHP Error was encountered
Severity: Warning
Message: fsockopen() [function.fsockopen]: unable to connect to localhost:8025 (Connection refused)
Filename: libraries/smtp.php
Line Number: 105
Thanks in advance
Ahamed
Apparently you are trying to connect to port 8025, and this fails. The default smtp port is 25, so either you used the wrong port number or there is no mail service running on port 8025 on localhost, but whatever the cause this is something you should probably change in your configuration somewhere.
Another option is to change the mail protocol from smtp to native php mail, refer to the CodeIgniter docs on how to do this (and make sure you set this up correctly - especially if you are using Windows, check php.ini).