Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
Ashburton #1
Using CFTHROW to catch invalid email addresses
I'm working on a helpdesk system that sends notification emails to users and
support consultants whenever they updated certain fields in the forms.
Unfortunately they want users to be able to add free-form email addresses to
the CC fields of the email. Our mail server is set so that if any of the
addresses does not exist then the email does not send. I don't know if this is
the way all mail servers work, but this one does and there is no changing it.
So I used CFTry and Catch to snag any bad addresses, but using CFCatch.Detail
only tells me "User Unknown" Actually I get the following:
This exception was caused by: javax.mail.SendFailedException: Invalid
Addresses; nested exception is: javax.mail.SendFailedException: 550 5.1.1 ...
User unknown .
But if I look at the mail log in the administrator it says:
Invalid Addresses; nested exception is: javax.mail.SendFailedException: 550
5.1.1 <cc@caris.com>... User unknown
So something knows which address is wrong and if I could find it then I could
tell users exactly which address is causing the problem. My question is, what
does the coldfusion administrator use to display the nonexistant email address,
[email]cc@caris.com[/email]? Is there a JAVA object that holds this variable that I could use
CFOBJECT and CFTHROW to display it?
Any help would be greatly appreciated.
Thanks
Ashburton Guest
-
Email to different addresses
Hi, I am designing a site for a company with dealers in different countries. For each product I have a 'request info' form with name, address,... -
#25342 [Opn->Bgs]: function gethostbynamel. This is returning ip addresses for invalid domains
ID: 25342 Updated by: pollita@php.net Reported By: getsuryya at rediffmail dot com -Status: Open +Status: ... -
#25342 [NEW]: function gethostbynamel. This is returning ip addresses for invalid domains
From: getsuryya at rediffmail dot com Operating system: LINUX PHP version: 4.3.2 PHP Bug Type: *Network Functions Bug... -
hiding email addresses
Could you tell me how to avoid having automated programs pick up the email addresses on your website so we avoid receiving so much junkmail? ... -
MikerRoo #2
Re: Using CFTHROW to catch invalid email addresses
I cannot easily duplictae this situation but I do know that CFCATCH creates
various undocumented variables -- depending on the exception type.
See the comments
[url]http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/[/url]
wwhelp.htm?context=ColdFusion_Documentation&file=0 0000225.htm for example.
You might find the information you need by adding:
<CFDUMP var="#CFCatch#">
to your page, temporarily, while triggering this exception type.
Cheers,
-- MikeR
MikerRoo Guest
-
PaulH #3
Re: Using CFTHROW to catch invalid email addresses
there are a variey of exceptions from javamail that you can trap. the
javax.mail.SendFailedException is always associated with email that could not
be sent (btw that's not the same thing as a bad address). that exception has 3
methods that you can use to query the state of your sent mail:
getValidSentAddresses() returns an array of valid addresses that were sent ok
getValidUnsentAddresses() returns an array of valid addresses that weren't
sent (server down, etc.)
getInvalidAddresses() returns an array of invalid addresses that weren't sent
(bad addresses)
note that what javamail thinks is a valid email address is laxer than what
most folks think. for instance joe@.com will pass javamail's address parse even
when it's set to strict. i'm not sure if that qualifies as kosher according to
the RFC but javamail certainly does.
PaulH Guest
-
Ashburton #4
Re: Using CFTHROW to catch invalid email addresses
Thanks PaulH. I saw the getInvalidAddresses() method in my research and played
around with it a bit, but due to my lack of knowledge with JAVA I couldn't get
it to work. How do I use this in ColdFusion to have it return the invalid
addresses?
Ashburton Guest
-
PaulH #5
Re: Using CFTHROW to catch invalid email addresses
i'm at home, i'll see what i have when i get into the office tomorrow.
PaulH Guest
-
PaulH #6
Re: Using CFTHROW to catch invalid email addresses
i think my original message was a bit misleading (i was thinking about using
javamail directly) as cf muddles the javamail exception a bit. see the code
below. some things to note:
our mailservers pass on all valid address email so my testing isn't all that
thorough
this only traps invalid email addresses (javamail bad address parse), so you
might be better off simply scrubbing the addresses first (see my first point)
you need to turn spooling off for this to work (you can do it via the cfmail
tag) otherwise bad email simply sits in the undelivered folder
<cftry>
<!--- send your mail, don't forget to turn OFF spooling if you want this to
work--->
<cfcatch type="Any">
<cfif cfcatch.detail contains "javax.mail.SendFailedException">
<cfset invalidAddresses="">
<cfloop index="i" from="1"
to="#arrayLen(cfcatch.rootCause.InvalidAddresses)# ">
<cfset
invalidAddresses=listAppend(invalidAddresses,cfcat ch.rootCause.InvalidAddresses[
i].toString())>
</cfloop>
</cfif>
</cfcatch>
</cftry>
<cfdump var="#InvalidAddresses#">
PaulH Guest
-
Ashburton #7
Re: Using CFTHROW to catch invalid email addresses
Sweet! That worked like a charm. Thanks a million.
Ashburton Guest



Reply With Quote

