Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't silence imap_open error notices in PHP

Tags:

php

imap-open

I am using PHP 5.3.5 and I am using

$this->marubox=@imap_open($this->server,$this->username,$this->password);

The @ sign should silence error reporting but it doesnt and I am sure that the error occurs on this line. I want my application to recognize the problem itself and react and get no NOTICE errors and I can't turn off error reporting for whole PHP because of my company development policy.

Without @ i am getting:

imap_open() [function.imap-open]: Couldn't open stream {pop3.seznam.cz:110/pop3}INBOX With it i get: Notice Unknown: Authentication failed (Authentication failed) (errflg=1)

If the login information is ok it opens the connection and no errors occur.

I always get NOTICE error when imap_open doesnt manage to connect and it's messing up with my JSON results. How to silence it please?

like image 415
Ragnar Avatar asked Mar 24 '11 16:03

Ragnar


1 Answers

I added

$this->marubox=@imap_open($this->server,$this->username,$this->password);
imap_errors();
imap_alerts();

and imap_errors(); and imap_alerts(); do the magic :)

like image 186
Ragnar Avatar answered Oct 24 '22 05:10

Ragnar