PHP:PEAR邮件帮助 [英] PHP: PEAR mail help
问题描述
严格标准:非静态方法Mail :: factory()应该不被静态调用,假设$ C与C:\Program文件(x86)中的不兼容的上下文\Apache Software Foundation\Apache2.2\htdocs\ClientPortal\classes\SupportTickets.php在线356
严格标准:非静态方法PEAR :: isError()不应该静态调用,假设$这是来自C:\PHP\PEAR\Mail\smtp.php中的不兼容上下文365
严格标准:非静态方法PEAR :: isError()不应静态调用,假设$ C来自C:\PHP\PEAR\Net\SMTP中的不兼容上下文。 php on line 386
严格标准:非静态方法PEAR :: isError()不应静态调用,假设$ C来自C:\PHP\PEAR\Net\\中的不兼容上下文\\ SMTP.php在线391
严格标准:不tatic方法PEAR :: isError()不应该静态调用,假设$ this来自C:\PHP\PEAR\Net\SMTP.php在行398上的不兼容上下文
严格标准:非静态方法PEAR :: isError()不应该静态调用,假设$ C来自C:\PHP\PEAR\Net\SMTP.php在第441行的不兼容上下文
严格标准:非静态方法PEAR :: isError()不应该被静态调用,假设$ C来自C:\PHP\PEAR\Net\SMTP.php在行230上的不兼容上下文
严格标准:非静态方法PEAR :: isError()不应静态调用,假设$ C来自C:\PHP\PEAR\Net\SMTP.php行445上的不兼容上下文$
严格标准:非静态方法PEAR :: isError()不应静态调用,假设$ C来自C:\PHP\PEAR\Mail\smtp.php中的不兼容上下文行376
严格标准:非静态方法P EAR :: isError()不应该被静态调用,假设$这是来自不相容的上下文C:\PHP\PEAR\Net\SMTP.php第526行
严格标准:非-static方法PEAR :: isError()不应静态调用,假设$ C来自C:\PHP\PEAR\Net\SMTP.php中的不兼容上下文,行230
严格标准:非静态方法PEAR :: isError()不应该被静态调用,假设$这是来自C:\PHP\PEAR\Net\SMTP.php中的不兼容上下文在第529行
严格标准:非静态方法PEAR :: isError()不应静态调用,假设$ this来自C:\PHP\PEAR\Net\SMTP.php第532行
严格标准:非静态方法PEAR :: isError()不应静态调用,假设$ this来自C:\PHP\PEAR\Net\SMTP.php第441行的不兼容上下文
严格标准:非静态方法PEAR :: isError()不应该静态调用,假设$这是来自C:\PHP\PEAR\Net\SMTP.php中的不相容的上下文在第230行
严格标准:非静态方法PEAR :: isError()不应该被静态调用,假设$这是来自C:\PHP\PEAR\Net\SMTP.php在线445上的不兼容上下文
严格标准:非静态方法PEAR :: isError()不应静态调用,假设$ C来自C:\PHP\PEAR\Net\SMTP.php中的不相容的上下文在线550
严格标准:非静态方法PEAR :: isError()不应该静态调用,假设$ C来自C:\PHP\PEAR\Net\SMTP.php行694上的不兼容上下文
严格标准:非静态方法PEAR :: isError()不应静态调用,假设$ C来自C:\PHP\PEAR\Net\SMTP.php中的不兼容上下文,行230
严格标准:非静态方法PEAR :: isError()不应该称为静态的,假设$这是来自C:\PHP\PEAR\Net\SMTP.php在线698上的不兼容上下文
严格标准:非静态方法PEAR :: isError()不应该静态调用,假设$这是来自C:\PHP\PEAR\Net\SMTP.php在第706行的不相容的上下文
严格标准:非静态方法PEAR :: isError()不应该静态调用,假设$这是来自C:\PHP\PEAR\Net\SMTP.php在行230上的不兼容上下文
严格标准:非静态方法PEAR :: isError()不应静态调用,假设$ this来自C:\PHP\PEAR\Net\SMTP.php行1017上的不兼容上下文
严格标准:非静态方法PEAR :: isError()不应该静态调用,假设$ C来自C:\PHP\PEAR\Net\SMTP.php中的不相容的上下文,第415行
严格标准:非静态方法PEAR :: isError()不应该被调用s假设$ this来自C:\PHP\PEAR\Net\SMTP.php中的不兼容上下文$ 230
严格标准:非静态方法PEAR ::不应该静态地调用isError(),假设$ C来自C:\Program Files(x86)\Apache Software Foundation\Apache2.2\htdocs\ClientPortal\classes\SupportTickets.php中的不兼容上下文线364
邮件成功发送!
这是我的代码:
function submitTicket(){
$ from =Billy Jones< billy.jones@networkroi.co.uk>;
$ to =helpdesk< helpdesk@networkroi.co.uk>;
$ subject =电子邮件测试!;
$ 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>);
}
}
有些人可以帮助我
我在这里提出了同样的问题,并找到了一个真正的解决方案(而不是屏蔽错误)。请阅读以下问题的答案了解更多详情,但基本上只需按照以下三个编辑方式进行。
< hr>
查找 php / pear / Mail.php
,转到第74行,然后更改:
function& factory($ driver,$ params = array())
to
static function& factory($ driver,$ params = array() )
另外在 php /pear/Mail.php
转到第253行并更改:
$ addresses = Mail_RFC822 :: parseAddressList($ recipients,'localhost',false);
至
$ Mail_RFC822 = new Mail_RFC822();
$ addresses = $ Mail_RFC822-> parseAddressList($ recipients,'localhost',false);
查找 php / pear /PEAR.php
,转到第250行并更改:
函数isError($ data,$ code = null)
to
静态函数isError($ data,$ code = null)
为了展示如何解决这个问题,阿玛尔!
I'm trying out the mail pear package. It successfully sends an email but give me the following error:
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!
Here's my code:
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>");
}
}
Can some one help me out here?
I asked the same question over here, and found a real solution (instead of masking errors). Read the answer to the question below for more details, but basically just follow the three edits below.
How to not call a function statically in php?
Find php/pear/Mail.php
, go to line 74 and change:
function &factory($driver, $params = array())
to
static function &factory($driver, $params = array())
Also in php/pear/Mail.php
go to line 253 and change:
$addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false);
to
$Mail_RFC822 = new Mail_RFC822();
$addresses = $Mail_RFC822->parseAddressList($recipients, 'localhost', false);
Find php/pear/PEAR.php
, go to line 250 and change:
function isError($data, $code = null)
to
static function isError($data, $code = null)
Thanks for Amal for showing how to fix this!
这篇关于PHP:PEAR邮件帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!