Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
<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, | |||
jb.bid_ID, jv.vendor_ID |
FROM | ((junction_bid_ccc jb | ||
LEFT | |||
JOIN | junction_vendor_ccc jv | ||
ON | jb.cccode_ID = jv.cccategory_ID) |
LEFT | |||
JOIN | lookup_contact lc | ||
ON | lc.vendor_new_ID = jv.vendor_ID) | ||
LEFT | |||
JOIN | Bid b | ||
ON | b.new_bid_ID = jb.bid_ID | ||
WHERE | jb.bid_ID = #thisBidID# | ||
AND | lc.contact_email <> '' | ||
AND | lc.contact_email IS NOT NULL | ||
GROUP | |||
BY | lc.vendor_new_ID, lc.contact_email, lc.contact_lname, | ||
lc.contact_fname, b.new_bid_ID, b.ReferenceNumber, |
b.Title,
b.Description, jb.bid_ID, jv.vendor_ID |
</cfquery>
<cfset thisReferenceNumber = list_sendto.ReferenceNumber>
<cfset thisTitle = list_sendto.Title>
<cfmail query="list_sendto" to="#contact_email#" from="whatever@whatever.com"
subject="Bid Notification" server="emailsrv1.cityofnewport.priv"
groupcasesensitive="no">
<p>You are receiving this message because .... etc.