RE: [PEAR] Re: [NEWBIE] Mail Help

From: Date: Mon, 21 Feb 2005 19:17:24 +0000
Subject: RE: [PEAR] Re: [NEWBIE] Mail Help
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17601@lists.php.net to get a copy of this message
Okay, so below is the code I'm using. I modified it to be if(PEAR::isError($mail)){ but that still returns a false positive. For some odd reason, it won't send the email and will NOT show an error. Any ideas? $recips = $Recip.'; '; $recips .= $Email; require_once('config.php'); require_once('Mail.php'); require_once('PEAR.php'); $headers['From'] = $Name." <".$Email.">"; $headers['Subject'] = $Subject; $headers['To'] = $Recip; $headers['Cc'] = $Email; $comments = wordwrap($Comments, 70); $MessageHeader ="This is an email from the Ridge Swim Club Website.\n\n"; $MessageHeader .="This message was sent by:\nName: $Name\nEmail: $Email\n\n"; $MessageBody = ">========== Message ==========<\n\n"; $MessageBody .= $comments."\n\n"; $MessageBody .= ">========== End Message ==========<\n"; $MessageFooter = "Message sent on: ".$Today." at ".$Time; $WholeMessage = $MessageHeader.$MessageBody.$MessageFooter; $Message = eregi_replace($breaks, "\n", $WholeMessage); $message = stripslashes($Message); $mail = &Mail::factory($method, $params); $mail->send($recips, $headers, $message); if(PEAR::isError($mail)){ $error = $mail->toString(); $error2 = $mail->getMessage(); echo "<b>".$error2."</b><br />".$error; $_REQUEST['pageid'] = '23'; } My config.php filehas the method set to 'smtp' and the $params[] array with all the correct info filled in. ~Brett -----Original Message----- From: Michael Wallner [mailto:mike@php.net] Sent: Monday, February 21, 2005 1:56 PM To: pear-general@lists.php.net Subject: [PEAR] Re: [NEWBIE] Mail Help Hi Brett Patterson, you wrote: > Hello all. I am new to using PEAR, but not so much to PHP. I was looking > for a little help. Phew :) I'd suggest that you have a look at the PEAR manual first... Here's a short example on how PEAR_Error might be used: require_once 'PEAR.php'; require_once 'Mail.php'; $mail = &Mail::factory('mail', $params); if (PEAR::isError($mail)) { echo "Error: ", $mail->toString(), "\n"; // or echo "Error: ", $mail->getMessage(), "\n"; } funcion errorCb($e) { echo "Error: ", $e->getMessage(), "\n"; } PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'errorCb'); // effectivly the same as PEAR::setErrorHandling(PEAR_ERROR_PRINT); if (PEAR::isError($mail->send($to, $hdrs, $body)) { // no need to print the error once again, // errorCb() will print the error } HTH, -- Michael - < mike(@)php.net >

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