Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfmail w/ comma-delimited list in 'To' line fails if one address fails

Status
Not open for further replies.

j9

Programmer
Jun 6, 2001
90
US
I have a comma-delimited list of email addresses and am trying to use CFMAIL to send an email to each recipient in the list. It works fine IF all addresses are deliverable BUT if one address in the 'To' list is undeliverable, none of them get delivered. Any ideas why this would happen?

For now, I'm CFLOOP'ing through the list, using a separate CFMAIL with each email address.
 
The only way CFMAIL would care about a given address is if it's not formatted correctly and CFMAIL can't make sense of it.

Other than that, it doesn't much care. It has no knowledge of whether the address is valid (ie - it exists so someone will receive it), or if the message bounced for some other reason. You can, for example, send email to "hello.world@foo.bar" all day long and CF won't care (or even know) that it wasn't going anywhere.

So, if by "undeliverable" you mean "not well formatted"... simply check the addresses for formatting before you pass them to CFMAIL. A standard email format validation would probably do it.
Code:
<CFSET validAddresses = &quot;&quot;>
<CFLOOP index=&quot;whichAddress&quot; list=&quot;#myAddressList#&quot;>
   <!--- probably need to add some checking for valid ascii characters, too, to be 100% --->

   <!--- must only contain one @ --->
   <CFIF ListLen(&quot;#whichAddress#&quot;,&quot;@&quot;) EQ 2>
       <CFSET addressDomain = ListLast(&quot;#whichAddress#&quot;,&quot;@&quot;)>
       <!--- the last TLD should be between 2 and 4 characters in length --->
       <CFIF ListLen(&quot;#addressDomain #&quot;,&quot;.&quot;) GT 1 AND Len(ListLast(&quot;#addressDomain#&quot;,&quot;.&quot;) GTE 2 AND Len(ListLast(&quot;#addressDomain#&quot;,&quot;.&quot;) LTE 4>
          <!--- correctly formatted email address --->
          <CFSET validAddresses = ListAppend(&quot;#validAddresses#&quot;,whichAddress)>
       </CFIF>
   </CFIF>
</CFLOOP>

#validAddresses# now contains your new list of valid email addresses.

Pass that to CFMAIL, and it shouldn't complain.

-Carl
 
Actually, the email addresses were formatted correctly. What I mean by undeliverable is that the email address doesn't exist, for example, and therefore cannot be mailed (an error message shows up in the cfusion\mail\undelivr directory). The problem is that if one of the email addresses in the 'To' line is bogus, NONE of them will be sent.

Try CFmail'ing using your own email address and one that does not exist in the 'To' line and let me know how you make out.

Thanks!
 
Okaaaay... tried it... works fine... next?

No, seriously... I sent an email to hello.world@foo.bar (which doesn't exist) and my own email address... from a second email address that I have... no problem whatsoever in mailing. My address received the email, and the from address received the bounce message... but ColdFusion didn't know or care.

The thing is, ColdFusion simply wraps up the email packet and hands it off to the mail server. It doesn't know whether an address exists or not... that's for the mail server to handle.

I suppose it could depend on what platform and what mail server you use... but I can't believe that there's a mail server that can integrate so deeply that ColdFusion would know, as it's trying to send mail, that an address doesn't exist (the mail server doesn't even know that). Even if ColdFusion watched \undelivr, you wouldn't get a bounce message (and thus an entry in \undelivr) until the entire mail was committed and sent. And, unless you have something implicitly set up to periodically check it, ColdFusion doesn't even know anything is in \undelivr.

At least, that's my understanding... based on my experience thusfar with several ColdFusion setups.

What is an example of the addresses that are causing problems?

-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top