Re: Re: PEAR mail problem
| From: | brian | Date: | Tue, 11 Mar 2008 23:58:22 +0000 |
| Subject: | Re: Re: PEAR mail problem | ||
| References: | 1 2 3 4 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-28630@lists.php.net to get a copy of this message | ||
Paul SIngh wrote:
Hey David et all,
I tried what you stated, but I get the same results:
Fatal error: Call to undefined method PEAR_Error::send()...
<?php
include("functions.php");
require_once "Mail.php";
if(isset($_POST['submitButton']))
{
$allow = processForm();
if($allow)
processEmail();
}
function processEmail()
{
$from = "Webmaster <paulsingh10 <at> hotmail.com>";
$to = "<paulsingh10 <at> hotmail.com>";
$subject = "Registration Confirmation";
$body = "\n\nYour account is pending approval,
please be patient.\n\nThank you,\nPRWR Webmaster.";
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "*********";
$password = "*********";
$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); --LINE 35 BTW
!PEAR::isError($smtp) or die($smtp->getMessage());
}
No, not quite. Do you see why it might be a good idea to check for an error *before* trying to use send()?
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
if (PEAR::isError($smtp))
{
die("Here's your error right here: " . $smtp->getUserInfo());
}
$mail = $smtp->send($to, $headers, $body);
b