Re: try - catch is not so clear to me...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[snip]
>
>
>
> function send_confirmation_email($to, $subject, $body)
> {
>   $headers =    "MIME-Versin: 1.0\n" .
>                  "Content-type: text/plain; charset=ISO-8859-1;
> format=flowed\n" .
>                  "Content-Transfer-Encoding: 8bit\n" .
>                             "Reply-To: Contact <lamp.lists@xxxxxxxxx>\n".
>                  "From: Contact <lamp.lists@xxxxxxxxx>\n" .
>                  "X-Mailer: PHP" . phpversion();
>
>     mail($to, $subject, $body, $headers) or die(mysql_errno());
> }
>
> $body is "regular" confirmation text: "Thank you for subscribing. To
> activate your account klick on the following link..." etc.
>
>
>
>
> function send_email_with_error_to_admin($e, $content)
> {
>   $error_message  = "Caught exception: " . $e->getMessage() . "\n";
>   $error_message .= "Code : " . $e->getCode()."\n";
>   $error_message .= "File : " . $e->getFile()."\n";
>   $error_message .= "Line : " . $e->getLine()."\n";
>
>     $to_email = "lamp.lists@xxxxxxxxx";
>     $subject = "[Confirmation Error Report] ".$e->getMessage();
>     $content .=
> "\n--------------------------------------------------------------------------------------------------\n\n";
>     $content .= "Error Report:\n\n".$error_message;
>     $content .=
> "\n--------------------------------------------------------------------------------------------------\n\n";
>
>     send_confirmation_email($to_email, $subject, $content);
> }
>
>
>
>
>
Since your function doesn't return anything to the code that calls the
function, your check of

if (!send_confirmation_email($email, $subject, $content))

is always triggering the failure. Try adjusting your function to return the
result of the mail call to see if that handles the checks better


function send_confirmation_email($to, $subject, $body)
{
  $headers =    "MIME-Versin: 1.0\n" .
                 "Content-type: text/plain; charset=ISO-8859-1;
format=flowed\n" .
                 "Content-Transfer-Encoding: 8bit\n" .
                            "Reply-To: Contact <lamp.lists@xxxxxxxxx>\n".
                 "From: Contact <lamp.lists@xxxxxxxxx>\n" .
                 "X-Mailer: PHP" . phpversion();

    $result = mail($to, $subject, $body, $headers) or die(mysql_errno());

    return $result;

}

-- 

Bastien

Cat, the other other white meat

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux