House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

cftry/cfcatch around cfmail

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
hi there.
Tony Weeg
02/10/05 07:45 P
sup barney... thats what ive got...
Tony Weeg
02/10/05 08:13 P
hey matt...
Tony Weeg
02/10/05 08:20 P
matt.
Tony Weeg
02/10/05 09:28 P
joe,
Tony Weeg
02/10/05 10:03 P
Tony,
Calvin Ward
02/11/05 06:39 A
the query is this...
Tony Weeg
02/11/05 10:54 P
not do... i meant, look like...
Tony Weeg
02/10/05 09:26 P
hey matt.
Tony Weeg
02/11/05 10:54 A
8.00 2003.03.03.28
Tony Weeg
02/11/05 01:20 P
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Weeg
02/10/2005 07:45 PM

hi there. i have a set of code that gets a bunch of email addresses from a database, it then loops through that query, and sends an email once, for every email address. i have a cftry/cfcatch block around the cfmail tag, and if it catches an exception it is set in the cfcatch section to send me an email, but continue through the rest of the loop.  almost like, if it encounters and email problem, it doesnt continue, or send any of the other emails.... any ideas why? -- tony Tony Weeg macromedia certified coldfusion mx developer email: tonyweeg [at] gmail [dot] com blog: http://www.revolutionwebdesign.com/blog/ cool tool: http://www.antiwrap.com

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Barney Boisvert
02/10/2005 07:52 PM

Because of the loop.  There's only one CFMAIL tag, so if it errors, it's done executing.  If you want it to continue, you need this: <cfloop query="myQuery">   <cftry>     <cfmail ... >     </cfmail>     <cfcatch ...>     </cfcatch>   </cftry> </cfloop> cheers, barneyb On Thu, 10 Feb 2005 19:39:33 -0500, Tony Weeg <tonyweeg@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more ----- -- Barney Boisvert bboisvert@gmail.com 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Weeg
02/10/2005 08:13 PM

sup barney... thats what ive got... <cfquery name="GetPartnerEmailAddresses" datasource="#usersDatasource#">      select email from regions where email like '%@%.%' </cfquery> <cfloop query="GetPartnerEmailAddresses">         <cftry>   <cfmail to="tony@navtrak.net" from="tony@navtrak.net" subject="Test, please disregard" spoolenable="No">This is a test, please disregard.</cfmail>                  This worked!                   <cfcatch type="Any"> <cfmail to="tony@navtrak.net" from="TheWebsite" subject="Email Manager Error" spoolenable="No">This error happened on #DateFormat(Now(),'mm/dd/yyyy')# Here is what happened: Message: #cfcatch.message# Detail: #cfcatch.detail# </cfmail>                       This didnt work.             </cfcatch> </cftry> </cfloop> and what happens is... it looks like its worked, as i see 10 "This worked" on the screen, and only one "This didnt work", but @ the bottom of the screen in the debugging output, and exception error... and no emails go out at all :( ? tw On Thu, 10 Feb 2005 16:50:14 -0800, Barney Boisvert <bboisvert@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Barney Boisvert
02/10/2005 08:22 PM

I'd trust the output over getting emails for evaluating whether the code is doing what it should.  Most likely, the mail isn't getting delivered properly, though CF is sending it out. cheers, barneyb On Thu, 10 Feb 2005 20:09:05 -0500, Tony Weeg <tonyweeg@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more ----- -- Barney Boisvert bboisvert@gmail.com 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matt Robertson
02/10/2005 08:05 PM

Do you mean you are using cfmail's query attribute, or you are using a cfloop over a query result set with a cfmail inside of it?  Seems like the latter but I thought I'd better ask.  If the former its going to hit the try/catch and that'll be the end of the cfmail operation, I believe. Here's a chopped-down version of what I use.  The catch file does essentially what you described, although it stores all errors to a db and emails the lot in one shot at the end of the run. <cfloop   query="Addresses"   startrow="1"   endrow="#variables.RunRate#">   <cftry>   <cfmail     to="#Addresses.InclEmailAddr#"     from="#session.Trickler.myEmail#"       subject="#session.Trickler.MsgTitle#"     server="#Settings.myEmailServer#"     type="HTML">     #session.Trickler.PageText#   </cfmail>   <cfcatch type="Any">   <cfinclude template="includes/inc_errcatch_mail.cfm">   </cfcatch>   </cftry> </cfloop> -- --mattRobertson-- Janitor, MSB Web Systems mysecretbase.com

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Weeg
02/10/2005 08:20 PM

hey matt... and i use the same, as ive implemented your trickle code into a clients email blaster :) but not for this one... this is much smaller volume, maybe 200 or so at a time, and my mail server @ my office works fine with this volume... i sent the code in a follow up to barney's email... so, by what you say, in a cfmail scenario, any exceptions basically just crash the whole operation? so whats the point of cfcatch if you cannot elegantly handle a cfmail exception? tw On Thu, 10 Feb 2005 17:02:45 -0800, Matt Robertson <websitemaker@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matt Robertson
02/10/2005 09:35 PM

On Thu, 10 Feb 2005 20:18:09 -0500, Tony Weeg <tonyweeg@gmail.com> wrote: > so, by what you say, in a cfmail scenario, any exceptions basically > just crash the whole operation? Noooo :-).  What Barney said happens... or is supposed to.  He boiled down the same sort of layout I posted and apparently what it is you are doing. 1. The loop executes 2. The cfmail executes. If the cfmail throws then the catch executes instead 4. the loop continues and we go back to Step 1 on the next item in the loop. If that ain't happening for you I think you have something else mixing itself into the picture.  I would pick apart / debug the bejesus out of your catch code to see if you aren't getting another failure in there, which in turn is the real cause of the loop dying.  I've seen that happen before. -- --mattRobertson-- Janitor, MSB Web Systems mysecretbase.com

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Weeg
02/10/2005 09:28 PM

matt. how does that differ from what im doing? just wondering... also, what does the inc_errcatch_mail.cfm block do? tw On Thu, 10 Feb 2005 17:02:45 -0800, Matt Robertson <websitemaker@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dawson, Michael
02/10/2005 08:18 PM

I've seen this before.  I can't remember if I ever found a work-around or not.  You can set a variable in the catch block, then call the cfmail tag after you are done looping. It would make a little more sense to send a single email with all the errors than an email for each error.  Just as Matt said previously. sup barney... thats what ive got... <cfquery name="GetPartnerEmailAddresses" datasource="#usersDatasource#">      select email from regions where email like '%@%.%' </cfquery> <cfloop query="GetPartnerEmailAddresses">         <cftry>   <cfmail to="tony@navtrak.net" from="tony@navtrak.net" subject="Test, please disregard" spoolenable="No">This is a test, please disregard.</cfmail>                  This worked!                   <cfcatch type="Any"> <cfmail to="tony@navtrak.net" from="TheWebsite" subject="Email Manager Error" spoolenable="No">This error happened on #DateFormat(Now(),'mm/dd/yyyy')# Here is what happened: Message: #cfcatch.message# Detail: #cfcatch.detail# </cfmail>                       This didnt work.             </cfcatch> </cftry> </cfloop> and what happens is... it looks like its worked, as i see 10 "This worked" on the screen, and only one "This didnt work", but @ the bottom of the screen in the debugging output, and exception error... and no emails go out at all :( ? tw

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Weeg
02/10/2005 09:14 PM

the problem is, its a bad email address, so i dont know until the email tries to go out... and its like i get an IMMEDIATE no-go from the mail server (all the emails for this test, are local to the mail server that im sending through, so it knows RIGHT AWAY). man this is strange... tw On Thu, 10 Feb 2005 19:15:17 -0600, Dawson, Michael <md40@evansville.edu> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Joe Eugene
02/10/2005 09:44 PM

1. Write a simple method to validate emails.... boolean return type. isEmailAddress(String emAddr){}     i cant remember but there is a good regular expresssion out there. 2. Develop a concrete method to send emails instead of having reduntant code all over the place to send emails.     sendEmail(){}     Within the sendEmail, you can invoke isEmailAddress and boolean return type, if the validation fails,     You can also send an errMessage back to the view - > "Your email address is Invalid, please correct" The above is a working solution. HTH. Joe ----- Excess quoted text cut - see Original Post for more ----- wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Weeg
02/10/2005 10:03 PM

joe, this isnt the problem... the problem is that there is an invalid email address in there , not in its form, or whatever, it'll validate just fine, its just that the mail server rejects it... the email address is local to the mail server that they cfmx server uses... tw On Thu, 10 Feb 2005 21:41:55 -0500, Joe Eugene <jebebox@earthlink.net> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Barney Boisvert
02/10/2005 11:20 PM

What happens if you allow the messages to be spooled?  Does that alleviate the issue? cheers, barneyb On Thu, 10 Feb 2005 22:00:30 -0500, Tony Weeg <tonyweeg@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more ----- -- Barney Boisvert bboisvert@gmail.com 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 50 invites.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Calvin Ward
02/11/2005 06:39 AM

Tony, Are you saying that no error is fired and no email is received, but there's an email in the undelvr cfmail folder? Or maybe I should just ask, how are you determining the email did not deliver? - Calvin joe, this isnt the problem... the problem is that there is an invalid email address in there , not in its form, or whatever, it'll validate just fine, its just that the mail server rejects it... the email address is local to the mail server that they cfmx server uses... tw On Thu, 10 Feb 2005 21:41:55 -0500, Joe Eugene <jebebox@earthlink.net> wrote: > 1. Write a simple method to validate emails.... boolean return type. > isEmailAddress(String emAddr){} >    i cant remember but there is a good regular expresssion out there. > > 2. Develop a concrete method to send emails instead of having reduntant code > all over the place to send emails. >    sendEmail(){} >    Within the sendEmail, you can invoke isEmailAddress and boolean return > type, if the validation fails, >    You can also send an errMessage back to the view - > "Your email address ----- Excess quoted text cut - see Original Post for more ----- <md40@evansville.edu> > wrote: > > > I've seen this before.  I can't remember if I ever found a work-around > > > or not.  You can set a variable in the catch block, then call the cfmail ----- Excess quoted text cut - see Original Post for more ----- datasource="#usersDatasource#"> ----- Excess quoted text cut - see Original Post for more ----- please ----- Excess quoted text cut - see Original Post for more ----- bottom ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Weeg
02/11/2005 10:52 AM

i can determine that because, ive replaced all the email addresses with mine, and just put one bad one, in there, and i dont get them :( i do get VALID emails, if they are all valid... i know, its strange. tw ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Joe Eugene
02/11/2005 09:28 PM

> the problem is that there is an invalid email address in there > , not in its form, or whatever, it'll validate just fine What are you using to validate the email address, i dont see where are validating the email address comming out of the DB Query. > > > > <cfmail to="tony@navtrak.net" from="TheWebsite" subject="Email Manager the from is invalid... have you tried errors@myWebsite.com ? HTH Joe ----- Excess quoted text cut - see Original Post for more ----- wrote: ----- Excess quoted text cut - see Original Post for more ----- code > > all over the place to send emails. > >    sendEmail(){} > >    Within the sendEmail, you can invoke isEmailAddress and boolean return > > type, if the validation fails, > >    You can also send an errMessage back to the view - > "Your email address ----- Excess quoted text cut - see Original Post for more ----- <md40@evansville.edu> > > wrote: > > > > I've seen this before.  I can't remember if I ever found a work-around > > > > or not.  You can set a variable in the catch block, then call the cfmail ----- Excess quoted text cut - see Original Post for more ----- the ----- Excess quoted text cut - see Original Post for more ----- datasource="#usersDatasource#"> ----- Excess quoted text cut - see Original Post for more ----- please ----- Excess quoted text cut - see Original Post for more ----- Manager ----- Excess quoted text cut - see Original Post for more ----- bottom ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Weeg
02/11/2005 10:54 PM

the query is this... select emailAddress from Table where emailAddress like '%@%.%' now, i know this doesnt validate, but at least weeds out the malformed, or n/a or whatevers... there is a regex that removes the invalids after the sql filter is applied... i just didnt show that code... thats all :) but, i got it working now, all is well! :) thank ya tw ----- Excess quoted text cut - see Original Post for more -----

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Weeg
02/10/2005 09:26 PM

not do... i meant, look like... whats the code inside that file? tw On Thu, 10 Feb 2005 21:23:50 -0500, Tony Weeg <tonyweeg@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matt Robertson
02/11/2005 12:33 AM

> On Thu, 10 Feb 2005 21:23:50 -0500, Tony Weeg <tonyweeg@gmail.com> wrote: > > how does that differ from what im doing? It doesn't in principle, but maybe your cfmail code is the problem. That spoolenable is out of the ordinary, at least to me. As for my catch code, thats sorta complicated.  I cut out quite a lot of what I'm actually doing. The first thing I do before sending an email to cfmail is validate it against a series of regular expressions designed to individually flag specific problems with an email address.  If any are found, the list of *all* problems with the address are collected together and output to a variable, which then stores the html-formatted list of errors in a discrete db record.  The specific tests look like this if (Len(variables.InclEmailAddr) lt 6) {   variables.FailureList=variables.FailureList & "<li>" & inc_verify_email.Error1; } if (not Compare(FindNoCase("@",variables.InclEmailAddr),0)) {   variables.FailureList=variables.FailureList & "<li>" & inc_verify_email.Error2; } and there are 40 separate item-specific tests.  The error messages represented as variables here would be "an email address must be at least six characters long" and "an email address must contain at least one '@' sign." respectively. The 41st test is the usual gargantuan regex for an email validation. This is my "general failure" test that bats cleanup for the first 40 if they miss something. The purpose of this is to supply complete information to the non-tech admin so they can clean up their list (the system uses imports that are outside my control, so I can't validate at the import phase, which would be better).  I have found this level of user education to be optimal for clerical-level (or otherwise dimwitted) employees who are running mailings from my cms. So I am actually doing address validation BEFORE the cfmail statement (in that same loop).  The try/catch is meant to catch anything missed by the address validator, to make the system truly failure-proof (or as much as can be at least).  It collects data again, but this time it stores cfcatch.message and cfcatch.detail in the discrete record along with data identifying the record it fried on. At the end of the mailing process the list of all errors is output onto the screen, and emailed.  This could be a mighty big email message, but in actual practice its never gotten unmanageable. If you want I can put up what all the email tests are, along with a loop that shows it running (its just a cfif that wraps the cfmail statement) -- --mattRobertson-- Janitor, MSB Web Systems mysecretbase.com

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Weeg
02/11/2005 10:54 AM

hey matt. if i dont spoolenable... my imail server just doesnt work... with cfmx.... they problem isnt an invalid format of an email address, its the problem that the email address that its choking on is no longer an email address to my mail server. which is the same mail server that cfmx sends these out with... so im getting an immediate unknown user, and thats making all of them not go out :( tw On Thu, 10 Feb 2005 21:30:51 -0800, Matt Robertson <websitemaker@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Weeg
02/11/2005 12:15 PM

:( ok, i must say, it wasnt anything, i had a rule in my outlook that sent mail from myself, to myself, into a folder, that is no longer there :(  what this means?  outlook didnt bug, and that was my problem. testing with another address, all is well, and it looks like my code is workign after all! thank to all. and to all a good day! tw ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matt Robertson
02/11/2005 12:38 PM

> if i dont spoolenable... my imail server just doesnt work... with cfmx.... Hmmm... I've used Im,ail for years with CF.  I'm running Imail 8.11 with MX 6.1 Updater 1 (soon to be CF7 :D) In fact now that I have converted my client/human-driven mail to Smartermail I have dedicated my Imail license to do nothing but process CFMAIL-generated mail. Your CF code is pretty straightforward and should be bulletproof.  I think its time to start blaming another culprit, and given what you say about Imail I think I know who I want to blame :-) What are your CF admin mail server settings?  Your imail version? Running on port 25? -- --mattRobertson-- Janitor, MSB Web Systems mysecretbase.com

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Weeg
02/11/2005 01:20 PM

8.00 2003.03.03.28 port 25 with spoolenable = no all systems go. with spoolenable = yes or not there at all since its default anyway, all systems NO GO. tw ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matt Robertson
02/11/2005 04:56 PM

Well, that ain't right.  I know Imail releases tend to be pretty buggy, so I didn't upgrade until 8.10.  What you are experiencing may be due to the early-release nature of the s/w. I'm only dimly aware of spoolenable and its implications.  Anyone with a better understanding of it and mail servers out there want to hazard a guess on this?  Seems to me if CF can send the mail directly to the mail server's queue it should also be able to spool it and then send. Can't think of anything inside of Imail offhand that would influence this.  Either IMail is told to allow a connection in or the connection is never allowed in. -- --mattRobertson-- Janitor, MSB Web Systems mysecretbase.com


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

July 24, 2014

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference