Fwd: [PEAR] need help with using Mail.php

From: Date: Wed, 18 Oct 2006 17:36:58 +0000
Subject: Fwd: [PEAR] need help with using Mail.php
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-25525@lists.php.net to get a copy of this message
---------- 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? Also I do have an error routine when calling Mail, but it doesn't seem to get there. 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. 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


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