Does ColdFusion allow cfmail to be used in cfloop?

Does anyone know? I have verified the below code iterates at least once:

		<cfloop index="i" from="1" to="#ArrayLen(recipients)#">
			<cfmail to="#recipients[i][1]#" from="server@server" subject="Report A Problem Message from #CGI.SERVER_NAME#">
				<cfmailpart type="text">#textmessage#</cfmailpart>
				<cfmailpart type="html">#message#</cfmailpart>

I do not get anything though, and I have dumped #recipients[i][1]# and successfully gotten an email so that is why I am asking this question.


Hi Darren.

Yes, cfmail works inside a loop.

I used your code and just added my own array and it worked - got three different emails.

Did you check you mail settings in CF admin? You can also check the logs to see if a message was generated - that way you’ll confirm whether or not the email was created and sent out.


If you can bring it in as a query instead then cfmail has a query attribute…

<cfmail query="qryRecipients">
Body of message

Hi guys, thanks for the clarification we will have to check our log.