PHP: PEAR mail message error

99封情书 提交于 2019-12-11 00:56:49

问题


I can send an email by the code in this (url:http://stackoverflow.com/questions/712392/send-email-using-gmail-smtp-server-from-php-page)

but the errors shown as following...

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Mail/smtp.php on line 365

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 450

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 467

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 474

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 517

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 265

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 521

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Mail/smtp.php on line 376

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 628

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 809

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 265

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 813

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 821

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 265

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 825

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 829

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 265

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 834

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 656

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Mail/smtp.php on line 249

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Mail/smtp.php on line 285

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 952

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 265

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 955

Strict Standards: Non-static method Mail_RFC822::parseAddressList() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Mail.php on line 253

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 982

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 265

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 985

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 1063

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 265

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 1066

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 1126

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 265

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 1136

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 1141

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 491

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 265

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 494

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in /Users/abc/pear/share/pear/Net/SMTP.php on line 497

Strict Standards: Non-static method PEAR::isError() should not be called statically in /Applications/MAMP/htdocs/p/testEmail.php on line 27

Message successfully sent!

in php.ini file, I also change error reporting level to

"error_reporting = E_ALL ^ E_STRICT"

Could anyone help me to solve this problem?


回答1:


First you're telling PHP to show all errors and strict standard infractions. To ignore the Strict Standards (which are non fatal) change your error reporting level to

 // PHP.INI
 error_reporting=E_ERROR^E_PARSE

 //or better, inline with error_reporting()
 error_reporting(E_ERROR | E_PARSE);

The root of the error is PEAR's Mail Class definition. I'm using a Mac Server also and PEAR. It is the better solution for multiple emails, however, it will raise Strict Standard errors. You can ignore.

You probably have this line of code after your send() call.

 if (PEAR::isError($mail_object)) {print($mail_object->getMessage());}

I prefer taking this line out and instead using try/catch/exception instead.

I would change your error reporting level with one of the error reporting modifications to your PHP.INI file or inline (best option).




回答2:


If you're on a cPanel server, go into your PEAR packages and make sure that you've updated your Net Server and SMTP packages. You should install net_socket2 and net_smtp2 packages. This solved my problem with this issue after upgrading to PHP 5.6.



来源:https://stackoverflow.com/questions/12619350/php-pear-mail-message-error

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