Note Though some of you seem to think differently, this is not a duplicate of PHP: PEAR mail message error. That question asks how to suppress the strict notices, which I have no trouble doing. My question pertains to the behavior later on (the final error_reporting
call at the end of my code) after I turn error reporting back on.
I am sending mail with php's pear mail extension. To avoid the strict notices that are raised when I call its functions, I turn off strict error reporting while using it. However, after I turn strict error reporting back on, the notices that were avoided are reported.
Here is the code:
<?php
include_once "Mail.php"; /*from pear.php.net*/
error_reporting(E_ERROR);
$from = "some@emailaddress";
$to = "another@emailaddress";
$subject = "test email";
$body = "body of email";
$headers = array (
"From" => $from,
"To" => $to,
"Subject" => $subject);
$smtp = Mail::factory("smtp",
array (
"host" => "badhost",
"port" => "badport",
"auth" => true,
"username" => "baduser",
"password" => "badpw"));
$mail = $smtp->send($to, $headers, $body);
/*if this line is commented out "goodbye" is all that is returned.
if it is left in, the return is "goodbye" followed by three "strict standards"
notices*/
error_reporting(E_ALL);
die("goodbye");
?>
This is aggravating more than anything else. Perhaps Pear's destruct methods are raising the notices.
Any ideas on how to make them not appear while being able to turn full error reporting back on?
A notice similar to this is raised three times:
Strict standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\wamp\bin\php\php5.4.3\pear\Net\SMTP.php on line 491