Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

imap_open : couldn't open stream to my mail server

Tags:

php

email

imap

Notice: Unknown: Connection failed to mail.domain.com,143: Connection timed out (errflg=2) in Unknown on line 0

imap_open("{mail.domain.com:143/novalidate-cert}INBOX", 'login', 'password')

The port 143 is open, I'm not behind a firewall, my server uses self-signed certificates.

I really don't understand why I can not connect to my mail server

I searched everywhere but I found no answer..

like image 920
PASTAGA Avatar asked Apr 01 '14 13:04

PASTAGA


2 Answers

Thank you for your answers. My mistake was not coming from the connection but rather a loop that crashed the server when I had too much email :

imap_open("{mail.domain.com:143/novalidate-cert}INBOX", 'login', 'password')

$mails = imap_search($stream, 'UNSEEN');

rsort($mails);
foreach ($mails as $mailId) {
  imap_fetch_overview($stream, $mailId, 0);
} //that was the mistake when email number is too big!
like image 180
PASTAGA Avatar answered Oct 11 '22 01:10

PASTAGA


In my case, this did the trick:

imap_open("{mail.domain.com:110/pop3/notls}INBOX", 'login', 'password')
like image 31
Carl Avatar answered Oct 11 '22 00:10

Carl