php pear mail extension raises strict notices

末鹿安然 提交于 2019-12-12 00:49:12

问题


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

来源:https://stackoverflow.com/questions/16326502/php-pear-mail-extension-raises-strict-notices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!