Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Sending email at same time cfmail

New Here ,
Sep 05, 2012 Sep 05, 2012

Hi... Im using cfmail (CF8)  on a CFC, to allow users to sent email from a big mailing list.

It was working fine, but Today, two users started to send their own e-mails at same time, but we recieve the emails  mixed ...I mean the first email Subject, but with the second email Body, or the first body with the second Subject

Any Idea what should I Do?

592
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 05, 2012 Sep 05, 2012

Make sure that you are properly scoping your variables in your CFC.  Use the 'var' keyword when you create variables used inside your CFC functions, even query names.  Define all of your variables used inside the CFC immediately after any CFARGUMENT tags and before any other logic.  Something like this pseudo-code:

<cffunction name="myFunction" ...>

     <cfargument name="myArg1" ...>

     <cfargument name="myArg2" ...>

     <!--- Declare variables --->

     <cfset var myVar = "">

     <cfset var myQuery = "">

     <!--- Function logic --->

</cffunction>

HTH,

-Carl V.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 05, 2012 Sep 05, 2012
LATEST

Make your code thread safe by wrapping it inside a cflock tag.  See the documentation here: http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7f5d.html

Basically it will look something like this:

<cflock name="myEmailLock" type="exclusive" timeout="10">
      <cfmail>     
      ...
      </cfmail>
</cflock>

By wrapping your cfmail code with an exclusive lock like this only one user can run that code at any given time.  Note that this may introduce some timeout errors for other users trying to access this at the same time.  You will need to deal with that.  You may also want to include more code within the cflock tags depending on what you are doing.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources