Skip to main content
Known Participant
December 9, 2008
Question

CFMAIL test mode?

  • December 9, 2008
  • 5 replies
  • 1963 views
I have a query that is pulling email addresses from a user database (an older database in this case). Then the query results are being looped into a CFMAIL tag.

Is there a way to test the CFMAIL tag before it actually sends the email to prevent the script from crashing 50 records in if it finds a defunct email?

I've wrapped the CFMAIL in a <cfif> to prevent bad emails being passed in...but it's not fool proof. I don't want to run the script again only to have it crash not knowing what broke it!

How do I deal with something like this?

I've run the query and created a filter and output the email addresses so I could see with my own eyes what is passing to CFMAIL. Looks good so far, but with 750+ emails...I'm sure I could over look something.

Ugh.

Paul
    This topic has been closed for replies.

    5 replies

    Inspiring
    December 9, 2008
    paulferree wrote:
    > What is "the" isValid() function?
    >
    >

    http://livedocs.adobe.com/coldfusion/8/htmldocs/functions_in-k_37.html

    Description

    Tests whether a value meets a validation or data type rule.
    Known Participant
    December 9, 2008
    What is "the" isValid() function?

    Inspiring
    December 9, 2008
    quote:

    Originally posted by: paulferree
    What is "the" isValid() function?



    It's something you could have used had you not been storing lists of email addresses in single fields. If you are able, you should do something about that.
    December 9, 2008
    You could have just done a check with the IsValid() function and if the email is valid then proceed with the cfmail else do whatever needs to be done with non valid records in the database.
    Inspiring
    December 9, 2008
    What are you doing with your current if/else logic?
    Known Participant
    December 9, 2008
    Well...after doing some manual filtering using some regex to help me clean up the list. I've narrowed it down to only needing to check for blank email addresses and multiple addresses in a single field.

    Thanks
    Known Participant
    December 9, 2008
    Why is this code not working...it's still crashing and giving me a CF error:

    <cftry>

    <cfmail to="" from="noreply@paulferree.com" failto="paulferree@gmail.com" subject="Test email" >
    This is a test
    </cfmail>

    <cfcatch type="any">
    An error has occurred.<br>
    <cfdump var="#cfcatch#">
    </cfcatch>

    </cftry>
    Inspiring
    December 9, 2008
    - you can wrap your cfmail in a cftry/cfcatch block
    - use FAILTO attribute of cfmail tag to specify an email address
    delivery failure notifications should be sent to

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    Known Participant
    December 9, 2008
    Ahh..yes. I've never really had to use the cftry/catch, but sounds like a good solution, as well as your other one about failto parameter. Off to work...thanks!

    Paul