Thanks for the ideas Troy, Dawn, and Doug!
I decided to try out cfthread as my code was already much like what Troy
suggested.
Here's what I have now:
<cfthread name="sendPR" action="run">
<cfloop query="qEmails">
<cfif qEmails.personalized EQ True>
<cfset personalMessage = qEmails.message>
<cfelse>
<cfset personalMessage = "">
</cfif>
<cfset sendMail(qEmails.eMail, subjectMsg, personalMessage,
Template)>
<cfset sleep(1000)>
</cfloop>
</cfthread>
The only thing is the thread doesn't seem to run. The above code is inside a
CFC function, and the sendMail() call goes to another method in the same
CFC? I saw an example on the web where someone did this, so I think it's OK.
Any ideas what I might be doing wrong? Also, are there good ways to
trouble-shoot with cfthread. The code runs correctly when I comment out the
cfthread tags. But when they are in there, nothing seems to happen. No
thread ever shows up in the Server Monitor.
Thanks for any pointers!
Clarke
From: [email protected] [mailto:[email protected]] On Behalf Of Troy Jones
Sent: Thursday, May 21, 2009 5:25 PM
To: [email protected]
Subject: RE: [ACFUG Discuss] Sending large numbers of eMail via ColdFusion
Clarke,
We have a similar application that sends out mass mailings. In the past we
have handled this using cfthread. In this simplified example, the code is
using cfthread to set a 1 second interval between each email.
<cfthread name="#threadName#" action="run">
<cfoutput query="getContacts">
<cfset valid_email =
IsEmail(email_field)>
<cfif valid_email>
<!--- Build
email here --->
</cfif>
<!--- pause one second after
sending each email --->
<cfthread action="sleep"
duration="1000" />
</cfoutput>
</cfthread>
This seems to work pretty well although you may want to adjust the interval
(remember, in milliseconds). It has two purposes. First, it takes the
processing out of the way of the rest of your other processing. Secondly,
and maybe just as important, it will help prevent your mail server from
getting tagged as a spam source.
Hope this helps.
Troy Jones
Developer/Support Technician
Dynapp, Inc
http://www.dynapp.com
From: [email protected] [mailto:[email protected]] On Behalf Of Clarke Bishop
Sent: Thursday, May 21, 2009 4:59 PM
To: [email protected]
Subject: [ACFUG Discuss] Sending large numbers of eMail via ColdFusion
I'm trying to finish up a cfm/cfc page that will send out about 3,000 eMail
messages. The messages are press releases and they go to a database of
magazine editors, radio/TV stations, etc. Also, the messages have to be
individually personalized.
John told me: "Don't try to send 3000 all at once. You'll lock up your mail
spool. Do small 50-120 size batches every 10 minutes."
Plus, I got a timeout error when I tried to run the page.
So, please point me in the right direction. Right now, I'm thinking:
. Use cfschedule to call a page every 10 minutes. The page then
sends 100 messages.
. Keep track of which emails have been sent and which page of the
query should get sent next.
. Cancel the cfschedule after all the messages are done.
Does anyone have a better suggestion for how to go about this?
Thanks,
Clarke
-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform
For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink <http://www.fusionlink.com>
-------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.339 / Virus Database: 270.12.35/2124 - Release Date: 05/21/09
06:22:00
-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform
For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink <http://www.fusionlink.com>
-------------------------------------------------------------
-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform
For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------