Re: need help with using Mail.php

From: Date: Fri, 20 Oct 2006 00:02:12 +0000
Subject: Re: need help with using Mail.php
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-25563@lists.php.net to get a copy of this message
On 10/19/06, Paula Fether <gridzmaster@gmail.com> wrote:
Tried two examples: example at http://us3.php.net/mail: $mail_object =& Mail::factory("smtp", $params); $mail_object->send($recipients, $headers, $body);
This looks right.
results I get: Warning: send(Net/SMTP.php): failed to open stream: No such file or directory in /usr/lib/php/Mail/smtp.php on line 206 Warning: send(): Failed opening 'Net/SMTP.php' for inclusion (include_path='.:/php/includes:/usr/lib/php:usr/bin:usr/bin/php:/private/etc') in /usr/lib/php/Mail/smtp.php on line 206 Fatal error: Cannot instantiate non-existent class: net_smtp in /usr/lib/php/Mail/smtp.php on line 210
Well, this is, of course, because Net_SMTP isn't installed.
On 10/19/06, Justin Patrin <papercrane@gmail.com> wrote: On 10/19/06, Paula Fether <gridzmaster@gmail.com> wrote:
We've Got Mail!! But also this message: Fatal error: Call to a member function on a non-object in /usr/lib/php/Mail.php on line 90
You can't call Mail::send(). You have to call Mail::factory to get a Mail object, then call send on that object. See the examples.
On 10/19/06, Justin Patrin < papercrane@gmail.com> wrote:
On 10/19/06, Paula Fether <gridzmaster@gmail.com> wrote:
sudo pear upgrade Archive_Tar downloading Archive_Tar- 1.3.1.tgz ... Starting to download Archive_Tar- 1.3.1.tgz (15,102 bytes) .....done: 15,102 bytes upgrade ok: Archive_Tar 1.3.1 sudo pear upgrade PEAR downloading PEAR-1.4.11.tgz ... Starting to download PEAR-1.4.11.tgz (283,272 bytes)
..........................................................done:
283,272 bytes Optional dependencies: package `PEAR_Frontend_Web' version >= 0.5.0 is recommended to
utilize
some
features. package `PEAR_Frontend_Gtk' version >= 0.4.0 is recommended to
utilize
some
features. package `PEAR_Frontend_Gtk2' version >= 0.1.0 is recommended to
utilize
some
features. upgrade ok: PEAR 1.4.11 directory listing of /usr/lib/php shows
Archive         Net             PEAR.php        build
pearcmd.php
Console         OS               System.php      data
peclcmd.php
HTML            PEAR            XML             doc
test
Still can't find Mail.php
Because it was never installed. You need to read the output of the pear command. Now that you've upgraded PEAR you can install packages with package.xml 2.0. Install Mail again: pear install Mail
On 10/19/06, Justin Patrin < papercrane@gmail.com> wrote:
On 10/19/06, Paula Fether < gridzmaster@gmail.com> wrote:
---------- Forwarded message ---------- From: Paula Fether < gridzmaster@gmail.com > Date: Oct 19, 2006 8:15 AM Subject: Re: [PEAR] need help with using Mail.php To: papercrane@reversefold.com pear info PEAR gives: About PEAR-1.3.6 ================
Provides        Classes: OS_Guess, System
Package         PEAR
Summary         PEAR Base System
Description     The PEAR package contains:
                 * the PEAR installer, for creating,
                distributing
                 and installing packages
                 * the alpha-quality PEAR_Exception php5-only
                exception class
                 * the beta-quality PEAR_ErrorStack advanced
                error handling mechanism
                 * the PEAR_Error error handling mechanism
                 * the OS_Guess class for retrieving info about
                the OS
                 where PHP is running on
                 * the System class for quick handling common
                operations
                 with files and directories
                 * the PEAR base class
Maintainers     Stig Bakken < stig@php.net> (lead)
                Tomas V.V.Cox <cox@idecnet.com> (lead)
                Greg Beaver < cellog@php.net> (lead)
                Pierre-Alain Joye <pajoye@pearfr.org> (lead)
                Martin Jansen < mj@php.net> (developer)
Version         1.3.6
Release Date    2005-08-18
Release State stable Release License PHP License Release Notes * Bump XML_RPC dependency to 1.4.0
                * return by reference from PEAR::raiseError()
Release Deps    PHP >= 4.2
                Package Archive_Tar >= 1.1
                Package Console_Getopt >= 1.2
                Package XML_RPC >= 1.4.0
                ext xml ==
                ext pcre ==
                ext xmlrpc ==
Last Modified 2006-03-05 And pear upgrade PEAR gives downloading PEAR-1.4.11.tgz ... Starting to download PEAR-1.4.11.tgz (283,272 bytes)
..........................................................done:
283,272
bytes requires package `Archive_Tar' >= 1.3.1 PEAR: Dependencies failed
Yep, so upgrade that package first: pear upgrade Archive_Tar pear upgrade PEAR
On 10/19/06, Justin Patrin < papercrane@gmail.com > wrote:
On 10/18/06, Paula Fether <gridzmaster@gmail.com > wrote:
downloading PEAR-1.4.11.tgz ... Starting to download PEAR-1.4.11.tgz (283,272 bytes)
..........................................................done:
283,272 bytes Release for 'pear' dependency Release for 'pear' Release
for
'pear'
dependency 'PEAR_Frontend_Web' has state dependency
'PEAR_Frontend_Gtk2'
has
state
'alpha', requires 'stable'    'PEAR_Frontend_Gtk' 'beta',
requires
'stable'
                              has state 'beta',
                              requires 'stable'
upgrade failed
That output doesn't make sense to me.... could you do: pear info PEAR Then try: pear upgrade PEAR
On 10/18/06, Justin Patrin < papercrane@gmail.com> wrote:
On 10/18/06, Paula Fether < gridzmaster@gmail.com > wrote:
Yes, I did that twice.
Ok, well, if upgrading PEAR didn't work or it did work but
the
installer still says there are no package.xml 2.0 handlers
then
somehting is wrong. What happens when you do: pear upgrade -a PEAR
On 10/18/06, Justin Patrin < papercrane@gmail.com >
wrote:
On 10/18/06, Paula Fether < gridzmaster@gmail.com>
wrote:
I tried the install again and saw the message "No
handlers
for
package.xml
version 2.0" but I don't think that has anything to
do
with
Mail,
does
it?
The first lines of the install are Starting to download Mail-1.1.14.tgz (17,537 bytes) ......done: 17,537 bytes downloading Net_SMTP- 1.2.8.tgz ... So maybe it's downloaded but not installed?
Did you do the upgrade-all as I asked before? You need
to
update
your
PEAR package.
On 10/18/06, Justin Patrin < papercrane@gmail.com >
wrote:
On 10/18/06, Paula Fether < gridzmaster@gmail.com>
wrote:
Listing of /usr/lib/php is
Archive         Net             PEAR.php
build
pearcmd.php
Console         OS              System.php
data
test
HTML            PEAR
XML
doc
so apparently Mail.php wasn't installed.
Sounds like pear install -a Mail sisn't work....
On 10/18/06, Justin Patrin <
papercrane@gmail.com>
wrote:
On 10/18/06, Paula Fether <
gridzmaster@gmail.com
wrote:
Done, also added some more paths. No change.
Even
remembered
to
restart
Apache again. The new paths do show up in
the
error
message,
so
the
changes
are taking effect, but it still can't find
Mail.php
Did you look to see if Mail.php is actually
there?
Did you ge it installed via the pear command?
On 10/18/06, Justin Patrin <
papercrane@gmail.com >
wrote:
On 10/18/06, Paula Fether <
gridzmaster@gmail.com
wrote:
That's weird. Phpinfo now shows the
php.ini
path
as
/private/etc/php.ini
.
There must be another place where the
path
is
stored,
I'm
guessing.
Try editing that file then.
On 10/18/06, Justin Patrin <
papercrane@gmail.com >
wrote:
On 10/18/06, Paula Fether <
gridzmaster@gmail.com>
wrote:
Saved file as php.ini, restarted
Apache,
still
no
worky.
You still get the file not found
problem?
Run
phpinfo();
again
(on
your webserver) and look at the
php.ini
and
include_path
values.
Are
they what you expect?
On 10/18/06, Justin Patrin <
papercrane@gmail.com
wrote:
On 10/18/06, Paula Fether <
gridzmaster@gmail.com
wrote:
pear config-show says php_dir is
/usr/lib/php
phpinfo() says php.ini.default
is in
/etc
found php.ini.default and
un-commented
the
Unix
include_path,
then
added
/usr/lib/php saved php.ini.default but my
program
still
can't
find
Mail.php
So I'm guessing I didn't add the
path in
the
right
place, or
I
need
to
save
the file as php.ini?
It needs to be named exactly as
phpinfo()
says.
The
.default
version
just has the defaults in it. You
should
copy
it to
php.ini
and
change
it there. Then you need to restart
apache.
On 10/18/06, Justin Patrin <
papercrane@gmail.com >
wrote:
On 10/18/06, Paula Fether <
gridzmaster@gmail.com>
wrote:
Done, but it can't find
Mail.php:
Warning: main( Mail.php):
failed to
open
stream: No
such
file
or
directory
in
/Users/paulafether/Sites/gui4me.com/Temail.php
on
line 2
Fatal error: main(): Failed
opening
required '
Mail.php '
(include_path='.:/usr/lib/php')
in
/Users/paulafether/Sites/gui4me.com/Temail.php
on
line
2
Do: pear config-show and look for the php_dir line.
You
need to
add
that
path
to
your
include_path in your php.ini .
To
find
your
php.ini,
put
this
in a
script (at the top) and look
for
php.ini:
phpinfo();
Doing "which Mail.php " in
Terminal
also
comes
up
empty.
"which" is for finding binary
commands, so
that
won't
work
for
these
kind of files. You can try
using:
locate Mail.php but the locate database isn't
updated
right
away
and
may
not
find
it
until updatedb is re-run.
On 10/18/06, Justin Patrin <
papercrane@gmail.com >
wrote:
On 10/18/06, Paula Fether
<
gridzmaster@gmail.com
wrote:
It downloaded
Mail-1.1.14.tgz
and
Net_SMTP- 1.2.8.tgz,
then
said
First thing you should do
is:
pear list-upgrades then pear upgrade-all Once that's done, look
again
at:
pear help install You want pear install -a Mail
Net_SMTP
requires package
`Net_Socket'
requires package
`Auth_SASL'
Net_SMTP: Dependencies
failed
Here are the config
settings:
PEAR executables
directory
bin_dir
/usr/bin
PEAR documentation
directory
doc_dir
/usr/lib/php/doc
PHP extension
directory        ext_dir
/usr/lib/php/extensions/no-debug-non-zts-20020429
PEAR directory
php_dir
/usr/lib/php
PEAR Installer cache
directory
cache_dir
/tmp/pear/cache
PEAR data
directory            data_dir
/usr/lib/php/data
PHP CLI/CGI binary
php_bin
/usr/bin/php
PEAR test
directory            test_dir
/usr/lib/php/test
Cache TimeToLive
cache_ttl
3600
Preferred Package State
preferred_state
stable
Unix file mask
umask
22
Debug Log
Level                verbose
1
HTTP Proxy Server
Address
http_proxy
<not
set>
PEAR server
master_server
pear.php.net
PEAR password (for
password
<not
set>
maintainers) Signature Handling
Program
sig_bin
/usr/local/bin/gpg
Signature Key Directory
sig_keydir
/private/etc/pearkeys
Signature Key Id
sig_keyid
<not
set>
Package Signature Type
sig_type
gpg
PEAR username (for
username
<not
set>
maintainers) On 10/18/06, Justin
Patrin <
papercrane@gmail.com >
wrote:
On 10/18/06, Paula
Fether
<
gridzmaster@gmail.com>
wrote:
---------- Forwarded
message
----------
From: Paula Fether <
gridzmaster@gmail.com >
Date: Oct 18, 2006
12:06
PM
Subject: Re: [PEAR]
need
help
with
using
Mail.php
To:
papercrane@reversefold.com
Hi Justin, thanks
for
the
quick
response.
PEAR came with my
php
installation,
so I
thought
everything
was
already
here. That's why I
was
surprised
that it
couldn't
find
Mail.php.
So
I
just
downloaded it and
put it
in
the
directory
with
my
site.
So I
guess I
need to
download the whole
PEAR
package
and
do
an
install
then?
If
so,
are
there
any
precautions I need
to
take
concerning
other
programs
that
use
it?
Open up a terminal and
type:
pear help Then use it to do
things
like:
pear install Mail
Net_SMTP
Also I do have an
error
routine
when
calling
Mail,
but
it
doesn't
seem
to
get there.
Did you try the error
handling
methods
on
my
wiki?
Thanks again for
your
help.!
PS: I've had other
problems
with
paths,
maybe
this
is
another
one. I
had
to
manually add the
path to
mysqldump
in
Terminal
(mac
osx),
and
then
append
the PATH statement
in
php in
order
to do
mysqldump
from
there.
It's possible that
'pear'
isn't in
your
path.
Try
the
above
and
see if
it is. include_path in
PHP
is
different.
On 10/18/06, Justin
Patrin <
papercrane@gmail.com >
wrote:
On 10/18/06, Paula
Fether
<
gridzmaster@gmail.com
wrote:
Hi, I'm trying
to
send
simple
emails
from a
website.
I
used
to
just
use
"mail()" but
noticed
that if
someone
reads
the
headers
they
can
see
information
about
the
webhost
that
I'd
rather
not
send,
so I
tried
Mail.php.
At first it
couldn't
find
the
program so
I
downloaded
it.
Then I
wrote
the
following test
code:
<?php require_once "
Mail.php
";    //
use
PEAR
$recipients
= "
you@mail.com ";
$headers["From"]
= "
me@mail.com
";
$headers["To"]
=
"
you@mail.com
";
$headers["Subject"]
=
"test
with
remote
host";
$body = "just
testing
some
more
now";
$params["host"]
= "
mail.me.com";
$params["port"]
=
"25";
$params["auth"]
=
true;
$params["username"]
= "
owner@me.com ";
$params["password"]
=
"mypassword";
$mail_object =
&Mail::factory("smtp",
$params);
$mail_object =
Mail::send($recipients,
$headers,
$body);
if
(PEAR::isError($mail_object))
{
    echo("<p>" .
$mail_object->getMessage()
.
"</p>");
    }else{
echo("<p>Message
successfully
sent!</p>");
    }
?> But it gives the
error
"*Fatal
error*:
Call
to a
member
function
on
a
non-object in
*/mypath.com/Mail.php*
on
line
*90*".
That's where
Mail
calls
"function
send($recipients,
$headers,
$body)".
Help please?
A few things: 1) Did you install
via
the
PEAR
installer
or
by
manually
copying
the
file? You shoul
dbe
using
the
PEAR
installer.
2) Did you install
Net_SMTP?
The
smtp
backend
to
Mail
requires
this
package as well. 3) Are you
checking
for
errors
before
usin
your
object?
Likely
the
above problems are
causing
an
error to
be
returned.
See:
http://pear.reversefold.com/dokuwiki/doku.php?id=phpfaqs#what_does_call_to_undefined_method_xxxxxx_mean
-- Justin Patrin
-- Justin Patrin
-- Justin Patrin
-- Justin Patrin
-- Justin Patrin
-- Justin Patrin
-- Justin Patrin
-- Justin Patrin
-- Justin Patrin
-- Justin Patrin
-- Justin Patrin
-- Justin Patrin
-- Justin Patrin
-- Justin Patrin
-- Justin Patrin -- Justin Patrin

« previous php.pear.general (#25563) next »