I have an app in which the admin user sends notices to Vendors who have signed up to recieve emails when a new bid is posted.
When a user (admin) sends the notices, if there is a mal-formed or dead email address in the DB, it dislays my default error screen even though the send transaction was successful.
Any advice on how to prevent this?
Thanks in advance for your help
As well as Dan's suggestion.
You can use the <cftry><cfctach> syntax to provide specific error handling to specific exceptions generated by specifc code.
I.E. you could wrap the <cfmail...> tag with a <cftry>...</cftry> block and then create a specific <cfcatch...> block that handles the bad email address exception any way you desire. As Dan sugested I would sugest somehow collecting the bad email address and providing them to somebody that can clean them from the data.
You could than also have a defalult <cfcatch...> block that would handle any other type of exception and|or rethrow the exception out to your current exception handler.
Some people don't like the concept of try|catch syntax, but I like it and feel it is a pretty elegant solution for this type of thing.
OK thanks for all the help.
I think I left out a part. The user can't get into the system to delete- that needs to be done at my level.
When there's an addendum to send, the user sends out the attached file to all who have viewed the original Bid package. They would like to print the resulting page which shows the list of who the recepients were. When the error page comes up instead, they obviously can't print the list.
If the only way I can test for bad mail is to use FailTo, that test message would go out to 5000 vendor contacts- is there a way to show the resulting list even though some of the emails were bad?
IOW can code be used to ignore bad addresses and continue processing the rest?
I'm missing something here. If you have an email address in the correct format, you don't know if it's valid or not until you send mail to it. If it's valid, nothing happens. Otherwise, there is an Undeliverable mail reply.
On the ColdFusion side, all the cfmail tag does it generate a file and put it in the Spool folder.
So my question is, what is causing your error page to run?
|<cfset thisBidID = session.bid_ID>|
<cfquery name="list_sendto" datasource="#Request.BaseDSN#">
|SELECT||lc.contact_fname, lc.contact_lname, lc.contact_email,|
|b.ReferenceNumber, b.Title, b.Description,|
|ON||jb.cccode_ID = jv.cccategory_ID)|
|ON||lc.vendor_new_ID = jv.vendor_ID)|
|ON||b.new_bid_ID = jb.bid_ID|
|WHERE||jb.bid_ID = #thisBidID#|
|AND||lc.contact_email <> ''|
|AND||lc.contact_email IS NOT NULL|
|BY||lc.vendor_new_ID, lc.contact_email, lc.contact_lname,|
|lc.contact_fname, b.new_bid_ID, b.ReferenceNumber,|
|b.Description, jb.bid_ID, jv.vendor_ID|
<cfset thisReferenceNumber = list_sendto.ReferenceNumber>
<cfset thisTitle = list_sendto.Title>
<cfmail query="list_sendto" to="#contact_email#" from="firstname.lastname@example.org"
subject="Bid Notification" server="emailsrv1.cityofnewport.priv"
<p>You are receiving this message because .... etc.
Europe, Middle East and Africa