By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,738 Members | 1,852 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,738 IT Pros & Developers. It's quick & easy.

PEAR: Using PEAR_Error in Mail::send()

P: n/a
I'm trying to send e-mail using PEAR's Mail class--for testing purposes
actually, I've never had any problem with conventional mail(). This is
what my code looks like:

$mail_object=&Mail::factory('sendmail', $params);
if($mail_object->send($to, $headers, $body)){
header('Location: '.$url_ok);
}else{
header('Location: '.$url_ko);
}

This works (i.e., sends mail) but I know it isn't fine. My code never
shows any error, even after removing sendmail link... The send() method
returns "TRUE or a PEAR_Error object, if fails" and I just can't figure
out how to use that. PEAR online manual doesn't include an example of
error handling, at least in this chapter, and I'm rather new to object
oriented programming. I'd greatly appreciate a little example.
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hello,

On 10/28/2003 01:37 PM, Alvaro G Vicario wrote:
I'm trying to send e-mail using PEAR's Mail class--for testing purposes
actually, I've never had any problem with conventional mail(). This is
what my code looks like:

$mail_object=&Mail::factory('sendmail', $params);
if($mail_object->send($to, $headers, $body)){
header('Location: '.$url_ok);
}else{
header('Location: '.$url_ko);
}

This works (i.e., sends mail) but I know it isn't fine. My code never
shows any error, even after removing sendmail link... The send() method
returns "TRUE or a PEAR_Error object, if fails" and I just can't figure
out how to use that. PEAR online manual doesn't include an example of
error handling, at least in this chapter, and I'm rather new to object
oriented programming. I'd greatly appreciate a little example.


I don't use PEAR so I can't tell you what is wrong. However, I can
recommend this other class for composing and sending messages that also
has a sub-class specialized in deliverying messages directly with the
sendmail program. I can assure you that when the sendmail program is
missing, it will fail returning false and you can check the error class
variable to know more about the failure.

http://www.phpclasses.org/mimemessage

--

Regards,
Manuel Lemos

Free ready to use OOP components written in PHP
http://www.phpclasses.org/

Jul 17 '05 #2

P: n/a
*** Manuel Lemos escribió/wrote (6:16:34 29/10/2003):
I can assure you that when the sendmail program is missing, it will
fail returning false and you can check the error class variable to
know more about the failure.

http://www.phpclasses.org/mimemessage


Thank you for your remark, I didn't know about this class repository.

About PEAR, I finally got some inspiration. I guess you just have to
test returned value against true using the "===" operator and, if you
need further info in case or error, you can save that value into a
variable and just access its methods.
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.