Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP:PEAR邮件帮助_Php_Email_Pear - Fatal编程技术网

PHP:PEAR邮件帮助

PHP:PEAR邮件帮助,php,email,pear,Php,Email,Pear,我正在试用邮包。它成功发送了一封电子邮件,但出现以下错误: 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\Sup

我正在试用邮包。它成功发送了一封电子邮件,但出现以下错误:

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!
这是我的密码:

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>");
      }

}
函数submitTicket(){
$from=“比利·琼斯”;
$to=“帮助台”;
$subject=“电子邮件测试!”;
$body=“电子邮件测试主体”;
$host=“***”;
$username=“***”;
$password=“**********”;
$headers=数组('From'=>$From,
'至'=>$至,
“主题”=>$Subject);
$smtp=Mail::工厂('smtp',
数组('host'=>$host,
“auth”=>正确,
“用户名”=>$username,
“密码”=>$password));
$mail=$smtp->send($to、$headers、$body);
if(PEAR::isError($mail)){
echo(“”$mail->getMessage()”

”; }否则{ echo(消息已成功发送!

); } }

有人能帮我吗?

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

只要将错误报告设置设置为
E\u ALL&~E\u STRICT
,它们就会神奇地消失。

@require\u once“Mail.php”;
@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>");  }
$headers=array('From'=>$From,'To'=>$To,'Subject'=>$Subject); $smtp=@Mail::工厂('smtp',数组('host'=>$host,'port'=>$port,'auth'=>true), 'username'=>UName,'password'=>UPass)); $mail=@$smtp->send($to、$headers、$body); 如果(@PEAR::isError($mail)) {echo(“”$mail->getMessage()。“

”);} 其他的 {echo(“消息已成功发送!

”);}

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

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


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

function &factory($driver, $params = array())
$addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false);
function isError($data, $code = null)


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

function &factory($driver, $params = array())
$addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false);
function isError($data, $code = null)


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

function &factory($driver, $params = array())
$addresses = Mail_RFC822::parseAddressList($recipients, 'localhost', false);
function isError($data, $code = null)


感谢Amal演示如何修复此问题

从PHP5开始,从另一个类的非静态方法中调用另一个类的非静态方法是在
E_STRICT
下的verboten。当编写
PEAR\u-Mail
包时,这是PHP中一个有点晦涩的元编程黑客。因此,
PEAR\u Mail
就是因为这个而臭名昭著的

方法PEAR::isError()
可能应该是一个静态方法,但它不是,并且假设一个实例上下文中抛出了大量的
$this
PEAR_-Mail
在自己的实例上下文中静态调用它,因此PHP推断
$this
。。。这是各种各样的坏消息

PEAR\u Mail::factory()
应定义为
static
,但其原因并非只有原始作者知道。它将始终生成“非静态方法”警告消息,直到修补代码


注意:
自2010年以来,PEAR\u邮件一直未被触动。请不要用它。。。!对于其他选择,请使用谷歌,卢克

不确定,因为我通常手动安装PEAR包,但至少可以在这里找到Net_SMTP包进行手动安装:谢谢,这很有效!但现在我有不同的错误,虽然电子邮件已成功发送!我已经更新了我的问题。电子邮件发送了吗?看起来PEAR::isError的方法签名缺少static属性,这意味着如果通过PEAR::isError进行静态访问,它将引发E_STRICT错误。你可以将你的错误报告级别(在php.ini中或在使用ini\u集的php脚本中)更新为E\u ALL^E\u STRICT,看看它是否有效。呵呵,太好了,我应该写一个答案来获得代表分数。;-)很高兴它能工作。:-)这对我有帮助,请不要关闭这个问题,因为我相信这将有助于未来的谷歌解决这个错误,马克斯应该把他的评论作为一个答案,这应该与PHP5.3和5.4一起工作吗?在PHP5.4中,E_STRICT是E_ALL的一部分。我使用的是5.3.9,在使用错误报告(E_ALL^E_strict)时,不会显示严格的错误消息。使用安全吗?我被这个答案弄糊涂了。由于某种原因,当我抑制错误时。它不会发送电子邮件。有什么想法吗?与RichardW11相同的问题,抑制错误会停止发送电子邮件….:(如果这个问题有一个实际的答案,我觉得应该有一个比这个更好的答案,邮件包是否应该引发这些错误?简单地称之为非静态的不是更好吗?这就像说“关闭计算机,那么你将永远不会看到任何类型的错误!”@ekerner有趣的是,你应该说…问题的根源是pear。他们将其存储库移动到github,并放弃了那里的网站库。pear的更新版本正是这些更改,逐行进行。因此,如果你最终更新pear,这些更改将保持不变。对于一些人来说,进行几行编辑比upd更容易更新一个完整的旧系统。加上pear已被放弃,用于压缩机和其他性能更好的LIB。@这很公平,有很好的理由。尽管这些编辑在最新的更新中,我建议只更新pear。@MarcF不是真的,我使用了PHP5.5.12,但我仍然解决了这个问题too@skjulikaka我认为MarcF的意思是这个解决方案有效这不是PHP5.5的问题。我已经在pear中安装了mail,但找不到pear.PHP,它在哪里?omgIt只有在没有错误处理程序集的情况下才能工作,比如so
set\u error\u handler(function…
如果有,像这样还原
restore\u error\u handler();
然后调用这个问题