3

I have a cfmail sending out to approxiamately 8 people (dynamically). One of these addresses is incorrect and therefore the whole email is not sent out. Is there any settings in the coldfusion administrator or in the cfmail tag where this can be changed so it will send to the 7 correct people and only fail for the one person. I'm using CF8.

Adam Tuttle
  • 19,505
  • 17
  • 80
  • 113
Jason
  • 17,276
  • 23
  • 73
  • 114
  • Can you mail them one by one instead of putting them all in To: or CC:? – Henry Sep 01 '09 at 00:50
  • As Tomalak writes below, the only way around this is to send separate emails. As CFMail is written one invalid address will spoil the party. This makes sense as an malformed email address is an error. – Terry Ryan Sep 01 '09 at 11:56

2 Answers2

6

Old school:

<cfloop query="mails">
  <cftry>
    <cfmail from="#from#" to="#to#">
      <!--- ... --->
    </cfmail>
    <cfcatch>
      <div>
        Mail not sent. #cfcatch.detail#
      </div>
    </cfcatch>
  </cftry>
</cfloop>
Tomalak
  • 332,285
  • 67
  • 532
  • 628
  • Thank you and yes I understand this is a possibility. However, I was looking for a solution that did not involve looping through the addresses. It seems to me that with every other mail client if you have x good and y bad then x will get sent and y will fail, they won't all fail. Do you (or anyone) know why Coldfusion has not followed this? – Jason Sep 01 '09 at 12:35
  • The answer is, IMHO, ColdFusion is not an E-Mail client. It is a procedural/imperative/oo programming language with email sending capabilities. And sending mail is one step, as far as CF is concerned. It would even be harder to debug if it worked 90%, instead of failing as a whole. Try to employ some basic validity checking to the e-mail addresses beforehand. Nothing fancy, just so much that a bogus address fails at the mail server for being undeliverable and not in your app for being invalid. – Tomalak Sep 01 '09 at 14:02
1

You can preprocess the list of emails with IsValid() and remove any items from the list that fail.

ryber
  • 4,537
  • 2
  • 26
  • 50