RE: [PEAR] Mail class error handling

From: Date: Thu, 15 Apr 2004 19:16:22 +0000
Subject: RE: [PEAR] Mail class error handling
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11877@lists.php.net to get a copy of this message
> -----Original Message----- > From: Sean Brown [mailto:sean@sean-brown.com] > Sent: Thursday, April 15, 2004 8:57 PM > To: pear-general@lists.php.net > Subject: [PEAR] Mail class error handling > > > I'm perplexed why I do not get any error message from the PEAR > Mail class, even when I intentionally try to break it. For > instance, below, if I change the SMTP password to an incorrect > value, no error message is returned, and no message gets sent. > If I set it correctly, an email gets sent. Any insight would be > appreciated. > > $crlf = "\r\n"; > $hdrs = array( > 'From' => 'me@example.com', > 'Subject' => 'My test subject', > 'Reply-To' => 'me@example.com' > ); > $smtparray = array( > 'host' => 'mail.example.com', > 'auth' => TRUE, > 'username' => 'example@example.com', > 'password' => 'mailpass' > ); > > $mime = new Mail_mime($crlf); > $mime->setTXTBody($plaintextmessage); > $mime->setHTMLBody($htmlmessage); > $body = $mime->get(); > $hdrs = $mime->headers($hdrs); > $mailObj =& Mail::factory('smtp',$smtparray); > $mailObj->send($to, $hdrs, $body); > if (PEAR::isError($mailObj)) { > return $mailObj -> getMessage(); > } else { > return "E-mail successfully sent." > } You have to check the return value of send(). Try: $return = $mailObj->send($to, $hdrs, $body); if (PEAR::isError($return)) { echo 'Error!'; } else { echo 'E-mail successfully sent.' } Regards, Torsten Roehr > > -- > PEAR General Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

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