PEAR: Using PEAR_Error in Mail::send()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alvaro G Vicario

    PEAR: Using PEAR_Error in Mail::send()

    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=&M ail::factory('s endmail', $params);
    if($mail_object->send($to, $headers, $body)){
    header('Locatio n: '.$url_ok);
    }else{
    header('Locatio n: '.$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
    --
  • Manuel Lemos

    #2
    Re: PEAR: Using PEAR_Error in Mail::send()

    Hello,

    On 10/28/2003 01:37 PM, Alvaro G Vicario wrote:[color=blue]
    > 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=&M ail::factory('s endmail', $params);
    > if($mail_object->send($to, $headers, $body)){
    > header('Locatio n: '.$url_ok);
    > }else{
    > header('Locatio n: '.$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.[/color]

    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.



    --

    Regards,
    Manuel Lemos

    Free ready to use OOP components written in PHP
    Free PHP Classes and Objects 2026 Versions with PHP Example Scripts, PHP Tutorials, Download PHP Scripts, PHP articles, Remote PHP Jobs, Hire PHP Developers, PHP Book Reviews, PHP Language OOP Materials


    Comment

    • Alvaro G Vicario

      #3
      Re: PEAR: Using PEAR_Error in Mail::send()

      *** Manuel Lemos escribió/wrote (6:16:34 29/10/2003):[color=blue]
      > 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[/color]

      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
      --

      Comment

      Working...