首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP: PEAR邮件帮助

PHP: PEAR邮件帮助
EN

Stack Overflow用户
提问于 2010-10-29 00:24:18
回答 4查看 43.4K关注 0票数 33

我在试用邮寄的梨套餐。它成功地发送了一封电子邮件,但给了我以下错误:

代码语言:javascript
复制
Strict Standards: Non-static method Mail::factory() should not be called statically, assuming $this from incompatible context in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ClientPortal\classes\SupportTickets.php on line 356

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\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 C:\PHP\PEAR\Net\SMTP.php on line 386

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 391

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 398

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 441

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 230

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 445

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\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 C:\PHP\PEAR\Net\SMTP.php on line 526

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 230

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 529

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 532

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 441

Strict Standards: Non-static method PEAR::isError() should not be called statically,  assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 230

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 445

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 550

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 694

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 230

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 698

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 706


Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 230

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 1017

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 415

Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\PHP\PEAR\Net\SMTP.php on line 230


Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ClientPortal\classes\SupportTickets.php on line 364
Message successfully sent!

下面是我的代码:

代码语言:javascript
复制
function submitTicket(){

     $from = "Billy Jones <billy.jones@networkroi.co.uk>";
     $to = "helpdesk <helpdesk@networkroi.co.uk>";
     $subject = "Email Test!";
     $body = "email test body";

     $host = "***";
     $username = "***";
     $password = "**********";

     $headers = array ('From' => $from,
       'To' => $to,
       'Subject' => $subject);
     $smtp = Mail::factory('smtp',
       array ('host' => $host,
         'auth' => true,
         'username' => $username,
         'password' => $password));

     $mail = $smtp->send($to, $headers, $body);

     if (PEAR::isError($mail)) {
       echo("<p>" . $mail->getMessage() . "</p>");
      } else {
       echo("<p>Message successfully sent!</p>");
      }

}

有人能帮帮我吗?

EN

回答 4

Stack Overflow用户

发布于 2014-02-27 04:03:34

我在这里问了同样的问题,并找到了一个真正的解决方案(而不是掩饰错误)。阅读下面问题的答案以了解更多细节,但基本上只需遵循下面的三个编辑。

How to not call a function statically in php?

找到php/pear/Mail.php,转到第74行并更改:

代码语言:javascript
复制
function &factory($driver, $params = array())

代码语言:javascript
复制
static function &factory($driver, $params = array())

同样在php/pear/Mail.php中,转到第253行并更改:

代码语言:javascript
复制
$addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false);

代码语言:javascript
复制
$Mail_RFC822 = new Mail_RFC822();
$addresses = $Mail_RFC822->parseAddressList($recipients, 'localhost', false);

找到php/pear/PEAR.php,转到第250行并更改:

代码语言:javascript
复制
function isError($data, $code = null)

代码语言:javascript
复制
static function isError($data, $code = null)

感谢Amal展示了如何解决这个问题!

票数 32
EN

Stack Overflow用户

发布于 2011-11-30 06:20:47

严格的错误不会阻止代码正常工作。

只需将错误报告设置为E_ALL & ~E_STRICT,它们就会神奇地消失。

票数 11
EN

Stack Overflow用户

发布于 2012-07-01 19:13:34

代码语言:javascript
复制
@require_once "Mail.php";
$headers = array ('From' => $from,'To' => $to,'Subject' => $subject);
$smtp = @Mail::factory('smtp', array ('host' => $host,'port' => $port,'auth' => true,
        'username' => $UName,'password' => $UPass));

$mail = @$smtp->send($to, $headers, $body);

if (@PEAR::isError($mail))
{   echo("<p>".$mail->getMessage()."</p>"); }
else
{   echo("<p>Message successfully sent!</p>");  }

看:我在一些变量和方法之前使用了@符号。通过这种方式,您可以使用php5发送电子邮件。这是一种古老的方法,但应该是可行的。虽然您可能会被问及如何在配置中启用ssl,但这是小菜一碟。好好享受吧。当然,alernate的最新和伟大的技术是使用SwiftMailer

票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4044996

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档