• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] IMAP Notices spamming

#1
[eluser]Morty[/eluser]
Hi there !

I am currently debugging an IMAP connection process. In order not to have any "notice" or any errors during execution I am tackling any issue one might encounter.
Code:
function test_imap($address, $password, $type)
    {
        if(!$mail = @imap_open("{mx.entreprise.com:993/imap/ssl}INBOX", $address, $password, OP_SILENT, 1));
        {
            die("Could not connect");
        }
        return ($mail);
    }
For the purpose of testing, $adress does not exist, therefore I do obtain error messages. What I do not understand is why I do get notices even with an @:
Code:
Could not connect
A PHP Error was encountered
Severity: Notice
Message: Unknown: Login failed. (errflg=1)
Filename: Unknown
Line Number: 0

A PHP Error was encountered
Severity: Notice
Message: Unknown: Too many login failures (errflg=2)
Filename: Unknown
Line Number: 0
My general approach is "noticeless" programming, with no need to change the error reporting level when deploying an application but there I'm stuck. Does anyone have an idea ?

Thanks in advance,
Morty

Edit:

In fact, there are a lot of information that are given by imap_open as notices which end up being errors on your page. They are given back even after a die() statement. Why?

PHP maintains a collection of all IMAP errors and if it is not emptied, it shows at the end of your script. In order to get these errors and empty this collection, one should use the imap_errors() function.

Problem solved.

#2
[eluser]sophistry[/eluser]
that information and more is bundled into my imap_pop class at the wiki.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.