PHP PEAR 邮件致命错误
PHP PEAR Mail Fatal Error
我正在尝试使用 PEAR 发送交易电子邮件。我的 PHP 代码:
include('Mail.php');
include('Mail/mime.php');
$text = 'test text';
$html = '<html><body><b>HTML</b></body></html>';
$crlf = "\n";
$hdrs = array(
'From' => '***@***.com',
'Subject' => 'Test - PEAR mail'
);
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$mail = Mail::factory('smtp',
array ('host' => 'mail.***.com',
'auth' => true,
'username' => '***@***.com',
'password' => '***'));
$mail->send(***@***.com, $hdrs, $body);
结果:
"Fatal error: Call to undefined method PEAR::raiseError() in /home4/good7/php/Net/SMTP.php on line 349"
我查看了 SMTP.php 中的第 349 行:
return PEAR::raiseError('Invalid response code received from server', $this->code);
我假设错误出在我的代码中,而不是在 SMTP.php 中,但我找不到它。
此站点位于共享主机上。
任何见解表示赞赏。
您似乎没有可用的所需 PEAR 模块。在共享主机上,首先检查你是否按照他们自己的教程正确安装了 PEAR:
https://pear.php.net/manual/en/installation.checking.php
然后,如果安装不正确,请按照共享主机教程进行操作,考虑到您可能会受到托管服务提供商的限制,无法完成您需要完成的操作:
https://pear.php.net/manual/en/installation.shared.php
我正在尝试使用 PEAR 发送交易电子邮件。我的 PHP 代码:
include('Mail.php');
include('Mail/mime.php');
$text = 'test text';
$html = '<html><body><b>HTML</b></body></html>';
$crlf = "\n";
$hdrs = array(
'From' => '***@***.com',
'Subject' => 'Test - PEAR mail'
);
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$mail = Mail::factory('smtp',
array ('host' => 'mail.***.com',
'auth' => true,
'username' => '***@***.com',
'password' => '***'));
$mail->send(***@***.com, $hdrs, $body);
结果:
"Fatal error: Call to undefined method PEAR::raiseError() in /home4/good7/php/Net/SMTP.php on line 349"
我查看了 SMTP.php 中的第 349 行:
return PEAR::raiseError('Invalid response code received from server', $this->code);
我假设错误出在我的代码中,而不是在 SMTP.php 中,但我找不到它。
此站点位于共享主机上。
任何见解表示赞赏。
您似乎没有可用的所需 PEAR 模块。在共享主机上,首先检查你是否按照他们自己的教程正确安装了 PEAR: https://pear.php.net/manual/en/installation.checking.php
然后,如果安装不正确,请按照共享主机教程进行操作,考虑到您可能会受到托管服务提供商的限制,无法完成您需要完成的操作: https://pear.php.net/manual/en/installation.shared.php