Catch an Exception in CFMail

Discussion in 'Programming' started by monkeyvu, Aug 5, 2007.

  1. #1
    Hi guys,

    I have written a snippet of code

    <cffunction>
    <cftry>
    <cfmail to=a@a.a
    from=a@a.a
    subject="Hello"
    server="10.0.0.1">
    #TheFileContents#
    </cfmail>
    <cfcatch type="any">
    <cfreturn 6>
    </cfcatch>
    </cftry>

    <cfreturn 0>
    </cffunction>

    It has the following error : 08/06 12:33:44 Error [scheduler-1] - Unknown SMTP host: 10.0.0.1

    What I need is catching that exception, but it always returns 0 (never return 6 although it has an error). May you tell me that how can I catch an exception? In my code, it never throws an exception, it always returns 0??? I want it return 6 when it has errors.

    Thanks so much :)
     
    monkeyvu, Aug 5, 2007 IP