0

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

Community
  • 1
  • 1
susie derkins
  • 512
  • 2
  • 6
  • 17
  • 6
    Fun thought: tell us what the errors are. – Sammitch May 01 '13 at 21:07
  • Installed pear/Mail & pear/Net_STMP: cannot reproduce it with respective versions 1.2.0/1.6.1.... – Wrikken May 01 '13 at 21:13
  • According to what you posted, the strict errors have nothing to do with your code, rather the errors are raised within the lower layer mail code. Try upgrading the "pear mail" api. – Mike Purcell May 01 '13 at 21:19
  • @BenD - it's a similar question, but not quite the same. I'm trying a similar solution as answers to that one suggest, but I am having the issues when I reset the error reporting level to all – susie derkins May 02 '13 at 00:25
  • @mikepurcell - you are correct, those errors are coming from pear. Unfortunately, I have the latest version of pear. (though it is admittedly a bit old - over 3 years) – susie derkins May 02 '13 at 00:27
  • @Wrikken - huh. interesting. I'll try it on another machine and see if I get the same results. I'm running wampserver on windows 7. – susie derkins May 02 '13 at 00:28
  • @susiederkins: I'm quite certain that Pear Mail is no longer maintained, as such there will be no fixes in your future, unless you do them yourself, which is never a good idea, and more work for you. I suggest you look at a mail api which is actively developed. Take a look @ http://swiftmailer.org/ – Mike Purcell May 02 '13 at 00:34
  • 1
    @Wrikken - I get the same results as you (no notices raised) when I run it on a linux machine using php 5.3. However, I get the above results on my wampserver stack running php 5.4.3. – susie derkins May 02 '13 at 19:55

0 Answers0