Jump to content

Call to undefined method PEAR_Error::send() - HELP!!


lmaster

Recommended Posts

Hello all

 

I installed the mail and net_smtp PEAR modules though i am getting the following error when I type

c:\php mailer1.php

 

PHP Fatal error:  Call to undefined method PEAR_Error::send() in C:\php\mailer1.

php on line 24

 

 

This is my script:

 

<?php

require_once "Mail.php";

 

$from = "Lawrence Master <taxandaccountingassoc@gmail.com>";

$to = "Lawrence Master <taxandaccountingassoc@gmail.com>";

$subject = "Hi!";

$body = "Hi,\n\nHow are you?";

 

$host = "ssl://smtp.gmail.com";

$username = "taxandaccountingassoc@gmail.com";

$password = "XXXXX";

$port = "465";

 

$headers = array ('From' => $from,

  'To' => $to,

  'Subject' => $subject);

$smtp = Mail::factory('smtp',

  array ('host' => $host,

    'port' => $port,

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

}

?>

 

I would appreciate any help

 

Thanks

 

Link to comment
Share on other sites

btherl,

 

Thanks for your help.  Unfortunately, adding that those three lines simply shifted where it hangs by three lines further down,  here is my complete script with your addition and the output:

 

<?php

require_once "Mail.php";

 

$from = "Lawrence Master <taxandaccountingassoc@gmail.com>";

$to = "Lawrence Master <taxandaccountingassoc@gmail.com>";

$subject = "Hi!";

$body = "Hi,\n\nHow are you?";

 

$host = "ssl://smtp.gmail.com";

$username = "taxandaccountingassoc@gmail.com";

$password = "XXXX";

$port = "465";

 

$headers = array ('From' => $from,

  'To' => $to,

  'Subject' => $subject);

$smtp = Mail::factory('smtp',

  array ('host' => $host,

    'port' => $port,

    'auth' => true,

    'username' => $username,

    'password' => $password));

if (PEAR::isError($smtp)) {

    echo("<p>" . $smtp->getMessage() . "</p>");

  }

 

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

 

  if (PEAR::isError($mail)) {

    echo("<p>" . $mail->getMessage() . "</p>");

  } else {

    echo("<p>Message successfully sent!</p>");

}

?>

 

C:\php>php mailer1.php

<p>Unable to find class for driver smtp</p>PHP Fatal error:  Call to undefined m

ethod PEAR_Error::send() in C:\php\mailer1.php on line 27

Link to comment
Share on other sites

Actually the new code tells you why it's not working.  It gives this important message: "<p>Unable to find class for driver smtp</p>"

 

Here's the code that generates the error:

 

    function &factory($driver, $params = array())
    {
        $driver = strtolower($driver);
        @include_once 'Mail/' . $driver . '.php';
        $class = 'Mail_' . $driver;
        if (class_exists($class)) {
            $mailer = new $class($params);
            return $mailer;
        } else {
            return PEAR::raiseError('Unable to find class for driver ' . $driver);
        }
    }

 

So basically it attempted to include "Mail/smtp.php" and check for the Mail_smtp class, but was unable to find it.  So either Mail/smtp.php doesn't exist, or including it did not define the Mail_smtp class.  Can you see the Mail/smtp.php file?

Link to comment
Share on other sites

MAKING PROGRESS, Yes it was a file/directory placement issue, I'm past that, BUT NOW I AM HAVING PROBLEMS WITH SSL, I followed the advice on this page, but it still does not work:

 

http://forum.uniformserver.com/index.php?showtopic=1378

 

C:\php\PEAR>php mailer1.php

PHP Warning:  PHP Startup: openssl: Unable to initialize module

Module compiled with module API=20060613, debug=0, thread-safety=1

PHP    compiled with module API=20050922, debug=0, thread-safety=1

These options need to match

in Unknown on line 0

<p>Failed to connect to ssl://smtp.gmail.com:465 [sMTP: Failed to connect socket

: Unable to find the socket transport "ssl" - did you forget to enable it when y

ou configured PHP? (code: -1, response: )]</p>

C:\php\PEAR>

 

 

Link to comment
Share on other sites

It doesn't look like it, what's the correct procedure?

 

PHP Version 5.1.4

 

System Windows NT 6RTUWESQ 5.1 build 2600

Build Date May 4 2006 10:30:29

Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared"

Server API Apache 2.0 Handler

Virtual Directory Support enabled

Configuration File (php.ini) Path C:\php\php.ini

PHP API 20041225

PHP Extension 20050922

Zend Extension 220051025

Debug Build no

Thread Safety enabled

Zend Memory Manager enabled

IPv6 Support enabled

Registered PHP Streams php, file, http, ftp, compress.zlib

Registered Stream Socket Transports tcp, udp

Registered Stream Filters convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.*

 

Zend logo This program makes use of the Zend Scripting Language Engine:

Zend Engine v2.1.0, Copyright © 1998-2006 Zend Technologies

Link to comment
Share on other sites

All, its fixed...  It ended up being a bad install of PHP... I simply got the latest binaries and extracted into the PHP folder, and put back my php.ini file and it works like a charm now...  I guess the distribution I got off a book had dll's that were corrupted and mismatched.

 

Thank you everybody that tried to help!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.