Link to home
Start Free TrialLog in
Avatar of shooby
shooby

asked on

cfmail to multiple recipients?

Hi there..

I was wondering if someone could tell me how to send mail to multiple recipients.  right now i have:  <cfmail from="#FORM.E_mail#" to="Direct-orders@honey.ca" subject="Special Order"> but i'd like to send this to 4 (bob@honey.ca, mary@honey.ca..  etc..) different recipients.  how would i code this?  i have no experience in cold fusion so code examples would really help.  thanks!
Avatar of HamdyHassan
HamdyHassan

Did you try

<cfset email_list="mailone,mailtwo">


cfmail from="#FORM.E_mail#" to="#email_list#" .....


If this not working try different seprators like
<cfset email_list="mailone;mailtwo">
<cfset email_list="mailone|mailtwo">
<cfset email_list="mailone mailtwo">


If still have problem then you need
<cfmail query=" " ...etc
I found the following

<CFMAIL
TO="recipient1@foo.com,recipient2@foo.com"
FROM="sender@foo.com"
CC="recipient3@foo.com"
SUBJECT="Sample form emailer">


so try it and let me know
Avatar of shooby

ASKER

Hi..  i tried testing that but it didn't work..  separating it like that is suppose to work?  maybe i'm doing something wrong?..  any thoughts?  thanks..
you can separate the emails with a comma, or a space, and probably others as well.

just go:

<cfmail from=="#FORM.E_mail#" to="Direct-orders@honey.ca, bob@honey.ca, mary@honey.ca" subject="Special Order">

place the text of the mail here

</cfmail>


are you getting an error?  if so, can you post it?
<cfset mailto = "bob@honey.ca, mary@honey.ca ,mary@honey.ca">
<cfmail from=="#FORM.E_mail#" to="#mailto#" subject="Special Order">

Mail Text
</cfmail>

hi give this a try

<CFMAIL TO="bob<bob@honey.ca>, mary<mary@honey.ca>"
     FROM="Direct<Direct-orders@honey.ca>"
     SUBJECT="Special -Multiple- Order"
     TYPE="HTML">
         
     Checking
</CFMAIL>

let me know

K'Rgds
Anand
Tried a loop ?

regards,
idss
ASKER CERTIFIED SOLUTION
Avatar of cdillon
cdillon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shooby

ASKER

there is no error, but the recipients are just not recieving the email..  any suggestions?
Did you set the mail server in the administrator?  Are you allowed to send mail from that server?

If you didn't set the mail server in the admin you can use the code below:

<cfset email_list = "email1@dom.com,email2@dom2.com,email3@dom3.com">

<cfset sender = "sender_email@honey.ca"> <!--- replace this with the sender's email address --->


<cfset smtp_server = "smtp.domain.com"> <!--- use an smtp server that you know is allowed from the coldfusion server --->

<cfloop index="email_address" list="#email_list#">

<CFMAIL TO="#email_address#" FROM="#sender#" SUBJECT="Special Order" TYPE="HTML" server="#smtp_server#">
This is the body of the email (please replace me)
</CFMAIL>


</cfloop>
Avatar of shooby

ASKER

i think that the server is already set up..  (i'm not sure) but it was previously sending to one recipient, and i'm suppose to change it to 4 recipients.  because of that, i'm assuming it is already set up?  (or does it need to be set up for multiple recipients?)
Avatar of shooby

ASKER

hi cdillon..
i tried using the loop you provided and it said that i have to have an end tag?  where would i add that?
show us your code

you might need

</cfmail>

after the mail ends

or </cfloop> after the </cfmail>



Avatar of shooby

ASKER

below is my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<cfset email_list= "mary@honey.com,jane@honey.com">
<cfloop index="email_address" list="#email_list#">
<cfmail to="#email_address#" from="#FORM.E_mail#" subject="Special Order">

________________________________________________
Name:
#FORM.Title# #FORM.First_Name# #FORM.Last_Name#
________________________________________________
Company:
#FORM.Company#
________________________________________________
Address:
#FORM.Address1#
#FORM.Address2#
________________________________________________
City:
#FORM.City#
________________________________________________    
Province:
#FORM.Prov#
________________________________________________
Postal Code:
#FORM.Postal#
________________________________________________
Phone:
#FORM.Phone# Ext:#FORM.ext#
________________________________________________
E-Mail:
#FORM.E_mail#
________________________________________________
Referred to Direct by:
#FORM.referred#
________________________________________________


ORDER PRODUCTS

Purchase Order Number:
#FORM.purchase_order_nr#
________________________________________________
Delivery Date Requested (M/D/Y):
#FORM.delivery_date#

Item               Quantity
#item_1#          #qty_1#
#item_2#          #qty_2#
#item_3#          #qty_3#
#item_4#          #qty_4#
#item_5#          #qty_5#
#item_6#          #qty_6#
_______________________________________________
Quotation Requested:
#quotation#


TECHNICAL LITERATURE REQUEST

Product or Form Number:
#FORM.tech_form_nr#
_______________________________________________
Description:
#FORM.description#
_______________________________________________
Comments:
#FORM.Comments#



________________________________________________
</cfmail>

thanks..
Avatar of shooby

ASKER

there is no info on the server that it's sending it from, does that mean that it's sending from whatever server the site is sitting on?
Try this.  You need to add </cfloop>
______________________________________________________

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<cfset email_list= "mary@honey.com,jane@honey.com">
<cfloop index="email_address" list="#email_list#">
<cfmail to="#email_address#" from="#FORM.E_mail#" subject="Special Order">

________________________________________________
Name:
#FORM.Title# #FORM.First_Name# #FORM.Last_Name#
________________________________________________
Company:
#FORM.Company#
________________________________________________
Address:
#FORM.Address1#
#FORM.Address2#
________________________________________________
City:
#FORM.City#
________________________________________________    
Province:
#FORM.Prov#
________________________________________________
Postal Code:
#FORM.Postal#
________________________________________________
Phone:
#FORM.Phone# Ext:#FORM.ext#
________________________________________________
E-Mail:
#FORM.E_mail#
________________________________________________
Referred to Direct by:
#FORM.referred#
________________________________________________


ORDER PRODUCTS

Purchase Order Number:
#FORM.purchase_order_nr#
________________________________________________
Delivery Date Requested (M/D/Y):
#FORM.delivery_date#

Item               Quantity
#item_1#          #qty_1#
#item_2#          #qty_2#
#item_3#          #qty_3#
#item_4#          #qty_4#
#item_5#          #qty_5#
#item_6#          #qty_6#
_______________________________________________
Quotation Requested:
#quotation#


TECHNICAL LITERATURE REQUEST

Product or Form Number:
#FORM.tech_form_nr#
_______________________________________________
Description:
#FORM.description#
_______________________________________________
Comments:
#FORM.Comments#



________________________________________________
</cfmail>
</cfloop>
and yes, it will be sending from the server its sitting on.

if you want another server, try using:

<cfmail to="tolist" from="fromemail" server="serveryouwanttotry">

mail message

</cfmail>

no guarantees that that will work.  it depends on how the server is set up.

Avatar of shooby

ASKER

hi there..  i added the close loop tag and it works fine now..  thanks to everyone for all your help..  i used cdillon's coding method and substand really helped me out.  so i'm going to accept cdillon's answer and post an empty question to substand so that he/she gets the points too.
Avatar of shooby

ASKER

thanks for all your help.  greatly appreciated!
why thank you.

=)