PHP中的IMAP传入邮件服务器设置

I have searched and read so many questions regarding this. I am saving incoming emails in to a MySQL database. I am using pipe to script method and I have already set up those things and the file reads correctly when I receive an email.

The error I receive is:

$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to server: ' . imap_last_error());

I am confused with $hostname variable, I have tried many times and I failed.

Normally my server is localhost for MySQL. I tried with that, and my server uses SSL. I used this localhost:993/imap/ssl}INBOX, but none are working. What is the correct server for that variable?

imap.mydomain.org:993 ???

Please help me to resolve this problem. I am fed up with this.

Going by what you have said, have you tried:

{localhost:993/imap/ssl}INBOX

or

{imap.mydomain.org:993/imap/ssl}INBOX

If that doesn't work, could you try providing an error output?

The true error message is Certificate failure, as mentioned by OP.

To solve the issue, change the function to:

$mbox = imap_open('{imap.maydomain.org:993/novalidate-cert}INBOX', 'user@domain.com', 'userpass') or die('Cannot connect to server: ' . imap_last_error());

to bypass validating self-signed certificate.