blogo blogo - 1 year ago 149
PHP Question

PHP PEAR Mail Fatal Error

I am trying to send transactional emails with PEAR. My PHP code:


$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);

$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);

The result:

"Fatal error: Call to undefined method PEAR::raiseError() in /home4/good7/php/Net/SMTP.php on line 349"

I had a look at line 349 in SMTP.php:

return PEAR::raiseError('Invalid response code received from server', $this->code);

I am assuming that the error is in my code, not in SMTP.php, but I can't find it.

This site is on shared hosting.

Any insight appreciated.

Dez Dez
Answer Source

It looks like you don't have the needed PEAR module available. Being on a shared host, first check you have PEAR rightly installed following their own tutorial:

And after that, if it is not installed rightly, follow the shared host tutorial, taking in count you might be limited by your hosting provider in of the actions you need to accomplish:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download