Skip to main content
December 20, 2011
Question

CFmail errors- how to prevent error message from user?

  • December 20, 2011
  • 2 replies
  • 1723 views

Greetings

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.

Even though I have "required="yes" validate="email"" at intial Vendor sign up (I think email validation is better served using Javascript, I've heard anyway) inevitably, contact emails go bad- and there are about 5000 vendors in the system.

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

 

sakonnetweb

This topic has been closed for replies.

2 replies

ilssac
Inspiring
December 20, 2011

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.

December 21, 2011

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?

Thanks again....

sakonnetweb

Inspiring
December 21, 2011

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? 

Inspiring
December 20, 2011

In your cfmail tag, put a special email address in the FailTo attribute.  Then see what mail that address gets after each mailing and update your db accordingly.