CFMAIL sending to multiple addresses through the query

357 views
Skip to first unread message

blueyoda

unread,
May 30, 2007, 10:46:15 PM5/30/07
to cfaussie
Does anyone know how to send 1 email through cfmail with multiple
addresses in the cc field.
I have a query named USERS and need to cc all the users from this
table but I'm getting 1 email to each CCed user and multiple emails to
the To address.

<cfmail
to="#varables.my_Email_Address#"
query="USERS"
cc="#USERS.SB_USER_EMAIL_ADDRESS#"
from="#varables.default_email_address#"
subject="#form.Subject#">

help

Dale Fraser

unread,
May 30, 2007, 10:54:14 PM5/30/07
to cfau...@googlegroups.com
Just build a list of email addresses first.

Ie

<cfset emailTo = "" />
<cfloop query="users">
<cfset emailTo = listAppend(emailTo, users.email, ";") />
</cfloop>

<cfmail
to="#emailTo#"

Regards
Dale Fraser

http://dalefraser.blogspot.com

pha...@formstar.com

unread,
May 30, 2007, 11:19:55 PM5/30/07
to cfau...@googlegroups.com
On Thu, May 31, 2007 at 12:54:14PM +1000, Dale Fraser wrote:

> Just build a list of email addresses first.
>
> Ie
>
> <cfset emailTo = "" />
> <cfloop query="users">
> <cfset emailTo = listAppend(emailTo, users.email, ";") />
> </cfloop>
>
> <cfmail
> to="#emailTo#"
>

or:

<cfmail to="#valueList(users.email,";")#" ... >

Of course this is exposing everyone's mail address to everyone
on the list. It'd be better to do:

<cfmail to="SomeDummyEmail@appropriate_domain.com"
bcc="#valueList(users.email,";")#" ... >


Paul Haddon
Technical Services Manager
Formstar Print Technologies

blueyoda

unread,
May 30, 2007, 11:24:03 PM5/30/07
to cfaussie
Thanks all that did the trick :)

Andrew Scott

unread,
May 30, 2007, 11:41:06 PM5/30/07
to cfau...@googlegroups.com
Very bad idea...

First of all you only have a certain amount that this field can cope with,
secondly it can be seen by some antispam software as being spam.

The only exception to this rule, is if you have a workflow for keeping
people in the loop in intranet applications. But for general mail outs, wrap
the cfloop query around the cfmail tag.

Andrew Scott
Senior Coldfusion Developer
Aegeon Pty. Ltd.
www.aegeon.com.au
Phone: +613 8676 4223
Mobile: 0404 998 273

-----Original Message-----
From: cfau...@googlegroups.com [mailto:cfau...@googlegroups.com] On Behalf
Of blueyoda
Sent: Thursday, 31 May 2007 12:46 PM
To: cfaussie
Subject: [cfaussie] CFMAIL sending to multiple addresses through the query

AJ Mercer

unread,
May 31, 2007, 12:43:53 AM5/31/07
to cfau...@googlegroups.com
Just to verify, to my mind, it would not make any difference in terms of network traffic (number of emails going out) in either method - no?

1 email with 100 CCs Vs 101 separate emails (1 for the TO)

Dale Fraser

unread,
May 31, 2007, 12:56:25 AM5/31/07
to cfau...@googlegroups.com

It should be similar.

 

Either way the mail server has to send 100 messages.

 

It will however make a difference to Coldfusion, to Coldfusion it’s one mail request or 101.

 

Regards

Dale Fraser

 

http://dalefraser.blogspot.com

 

<br

Andrew Scott

unread,
May 31, 2007, 2:06:25 AM5/31/07
to cfau...@googlegroups.com

Actually it can make a difference, but only to the CF server. If the mail server is not inside your network, then it will be 1 email. Once it hits the mail server it will be 101 emails. However, if you loop over with my method it will be 101 emails from the coldfusion server.

 

But as far as I am concerned it is BAD practice to send so emails out for a mailing list, or mail out or email campaign with emails in the CC address. Its just wrong, and can cause problems with ISP’s and mail clients as well as antispam / antivirus software. Not to mention that, this field only can hold so many email addresses to begin with.

Simon Haddon

unread,
Jun 3, 2007, 4:22:42 AM6/3/07
to cfau...@googlegroups.com
Hi Paul,

Another Haddon.  Not too many of us :)


On Thu, May 31, 2007 at 12:54:14PM +1000, Dale Fraser wrote:

> Just build a list of email addresses first.
>
> Ie
>
> <cfset emailTo = "" />
> <cfloop query="users">
>     <cfset emailTo = listAppend(emailTo, users.email, ";") />
> </cfloop>
>
> <cfmail
>       to="#emailTo#"
>

or:

<cfmail to="#valueList(users.email,";")#"  ... >

Of course this is exposing everyone's mail address to everyone
on the list. It'd be better to do:

<cfmail to="SomeDummyEmail@appropriate_domain.com"
bcc="#valueList(users.email ,";")#"  ... >



Paul Haddon
Technical Services Manager
Formstar Print Technologies





--
Cheers
Simon Haddon
Reply all
Reply to author
Forward
0 new messages