I have develop a routine to open email boxes which are on different platform. It gives problem to open windows exchange if the code is running on linux and vice versa. How I can resolve this issue. I am using the following code open IMAP.
$hostname = '{pop.lcn.com:110/pop3}INBOX';
$username = 'abc#xyz.co.uk';
$password = 'xxxxx';
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to mail server: ' . imap_last_error());
$emails = imap_search($inbox,"ALL" );
particularly the mail box on this server was going to open the mail box. but now its not going to open and giving conneciton timeout problem. when I check it from windows server then it was working fine. Now I do not know what kind of changes have on server. that script is not running.
Related
I want to read a mail's inbox using PHP IMAP.
On phpinfo() i see both OpenSSL and IMAP enabled.
When trying to connect:
/* connect to inbox */
$hostname = "{imap-mail.outlook.com:993/imap/tls}INBOX";
$username = 'mail#...';
$password = 'password';
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Error: ' . imap_last_error());
It will always throw an error:
Can't connect to imap.glbdns2.microsoft.com,993: Connection refused (errflg=2)
On the outlook settings it says:
Why does this happen and how can I fix it?
I had almost the same problem with my email server. It was not accepting request from other third party servers which was using it. After sometimes, it came down to the increased banning rules I had set for the server. The fail2ban was now set to permanently ban offending IPs which tried to unsuccessfully login for more than three times. I was lucky since I managed this email server myself so I un-blacklisted the IP and it works fine. Firewall problem is the most likely cause of this. Try the following:
check your IP if it is blacklisted by any blacklist houses (the requesting server IP);
a site like https://mxtoolbox.com/ can help;
if you have another server (like VPS container), try running the code from it;
if all fails, you may have to contact the: imap-mail.outlook.com people for help.
I am trying to integrate IMAP on website, but i am stuck in the first itself. I am not able to establish the connection. The code that I used was:
$connect_to = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
//$connect_to = '{imap.gmail.com:993/imap/ssl}INBOX'; tried this method also
$user = 'abc#gmail.com';
$password = 'abc123';
$connection = imap_open($connect_to, $user, $password)
or die("Can't connect to '$connect_to': " . imap_last_error());
imap_close($connection);
I checked the firewall, authentication from gmail, allowed less secure app from gmail end, but everytime i am getting this error
Can't connect to '{imap.gmail.com:993/imap/ssl}INBOX': Can not authenticate to IMAP server: [ALERT] Please log in via your web browser: https://support.google.com/mail/account
Can anyone please tell why this is happening and how can i rectify it. I also would like to know is there a way where i can allow all web mails together, currently its only for gmail but i would like it to work for all server such as yahoo, hotmail, aol etc
I just moved my app to the cloud hosting. I was using imap_open to access mails in my gmail account. It worked fine.
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = '...#gmail.com';
$password = '****';
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
Now I get an error Unable to create selectable TCP socket (1176 >= 1024) Does anybody have any idea about this error. I appreciate any help.
Thanks.
It looks to me like you've hit the maximum amount of open file descriptors. Maybe restarting your system?
Problem
I want to connect to my mail box on my domain name. Unfortunately I couldn't succeed so far.
/* mail information */
$hostname = '{mail.domain.com:110/pop3}INBOX';
$user = 'mail#domain.com';
$pass = 'mypassword';
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Mail: ' . imap_last_error());
Error Output
Cannot connect to Mail: Certificate failure for mail.domain.com: Self-signed certificate or untrusted authority: C=US, S=Someprovince, L=Sometown, O=none, OU=none, CN=localhost, E=webaster#localhost
I also tried following;
1. approach
$hostname = '{mail.domain.com:110}INBOX';
After quite long time of waiting;
Cannot connect to Mail: [CLOSED] IMAP connection broken (server response)
2. approach
$hostname = '{mail.domain.com:110/pop3/novalidate-cert}INBOX';
Almost immediate response;
Cannot connect to Mail: Login aborted
At this point, I tried what I could find on PHP.net, Google and SOF without any success.
What could be the problem and what could be the solution? I don't think imap connection is hard to connect.
You can use /novalidate-cert in hostname parameter to bypass certificate validations in case you use self-signed certificates. See http://php.net/manual/de/function.imap-open.php for further information.
Well I've never used IMAP and POP in PHP, but it's evident to me that you're trying to connect via IMAP on a POP3 port. IMAP listens on port 143.
I have some php code that I'm trying to use to connect to gmail using imap. Here's the code:
$hostname = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
$tmp_username = 'username';
$tmp_password = 'password';
$inbox = imap_open($hostname, $username, $password) or die(imap_last_error());
And I get this error output everytime i try to connect:
Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX in /var/www/PHP/EmailScript.php on line 14
Login aborted
I dont understand what could be wrong!! I've heard of people having SSL errors but this doesnt seem to be one of those. Please please please help me!!!!!
Edit: When trying to connect through telnet-ssl to imap.gmail.com i get the following output:
Trying 74.125.155.109...
Connected to gmail-imap.l.google.com.
Escape character is '^]'.
And nothing else happens, it just sticks there
I was just about to ask if you had a firewall up when you edited your question.
Your router or firewall may be configured to block port 993. You will have to open it to allow communication on that port. If the machine has a system administrator, you'll have to ask them. Otherwise, check the firewall software and/or router.
Try the host
{imap.gmail.com:993/imap/ssl} without setting the folder INBOX.
Your code should be:
$hostname = '{imap.gmail.com:993/imap/ssl}';
$tmp_username = 'username';
$tmp_password = 'password';
$inbox = imap_open($hostname, $username, $password) or die(imap_last_error());
If the problem persist check if IMAP function is enabled or disabled in your server.