2 Replies Latest reply on Oct 11, 2006 8:36 AM by Newsgroup_User

    Sending emails in batches

    Level 7
      I need to have my looping mailer send out 200 emails every minute till all
      are sent. I have the code listed below that mails them all out at once.
      Novel for my 10 email tests, but when the first user uploads 5000 - 25000
      there will be problem. Anyone know a place to read up more on how to only
      send 200 per batch and then time it to pause for 1 minute (give or take)

      <cfif IsDefined ('Send_Mail')>
      <cfloop query="mailist">
      <cfset html = #campaign.html#>
      <cfset yourname = #mailist.name#>
      <cfmail from="#campaign.emailfrom#" to="#mailist.email#"
      failto="bounce@avemarialaw.edu" replyto="#campaign.emailreply#"
      server="*****" subject="#campaign.subject#">
      <cfmailpart type="html">
      <cfoutput>#replace(html,'name',yourname,"ONE")# <br /><br />
      Your name has been provided to Ave Maria School of Law by the Law School
      Admissions Council Candidate Referral Service.<br />If you wish not to
      receive future communications, <a
      href=" http://www.avemarialaw.edu/mailings/optout.cfm?email=#mailist.email#&name=#mailist.name#"> please
      click here.</a></cfoutput>
      </cfmailpart>
      <cfmailpart type="text/plain">
      <cfoutput>#campaign.plaintext#
      Your name has been provided to Ave Maria School of Law by the Law School
      Admissions Council Candidate Referral Service.<br />If you wish not to
      receive future communications, please copy and past this link into your web
      browser
      http://www.avemarialaw.edu/mailings/optout.cfm?email=#mailist.email#name=#mailist.name#
      </cfoutput>
      </cfmailpart>
      </cfmail>
      </cfloop>

      This is one of the last pieces I need to have done by tomorrow morning on
      this monster problem / project. Thanks for any help!


        • 1. Re: Sending emails in batches
          cfdoogan Level 1
          There are a few ways to build an email batch system. The three I know of work using the following techniques:
          1 - Meta refresh
          Send email addresses to database. Select first 200 addresses and send them the email. Delete these 200 out of the database. Set meta-refresh to reload the page after 60 seconds. This browser session will run until all email addresses are out of the database. Only problem with this is if the user closes the browser then the emails wont go out.
          2 - cfschedule
          If you have access to cfschedule you can programmatically create a new schedule to run every 60 seconds. Put the addresses in the database and send 200 emails then delete the emails out of the database. Once all the names are gone delete the scheduled process.
          3 - java.lang.Thread
          Loop over the database selecting 200 records at a time, tell the template to sleep for 60 seconds and then start the process all over again.

          Google cfemail batch
          • 2. Re: Sending emails in batches
            Level 7
            Did it a different way. Thanks!