Cfloop or cfmail query for mass emails?

Is there a “best practice” when sending a lot of email?

Would you:

cfloop query=TheEmails
  cfmail
/cfloop

or:

cfmail query=TheEmails

Any advantages/disadvantages to either approach?

I’m not talking a massive amount. Under 4,000 emails sent.

query, you have more control

Thanks Zack.

Just to verify, you mean use the query attribute of the cfmail tag, correct?

I ask because both statements used query attributes.

Can you elaborate what you mean by more control?

Dan

@dlegate what Zac mean by more control is using cfloop query = theEmails you can do whatever you want with the query data. For example

<cfloop query="theEmails">

    <cfif isValid("email", theMails.to)>
        <cfmail ........>
    
        </cfmail>
    <cfelse>
        <cflog text = "the mail address #theMails.to# is invalid" file="mailFailed.log">
    </cfif>

</cfloop> 

Also, the query attribute of the cfmail tag is marked as unimplemented <cfmail> :: Lucee Documentation. So using the cfmail query attribute is not the best approach.

1 Like

Excellent! Appreciate the detailed explanation!

2 Likes

According to the docs, this is not implemented.

Do you have a provider that will accept mass mailings? Or are you self hosting your MTA?

Our SMTP has this server whitelisted for sending mass mails, yes.

1 Like