[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

Problem with .cfm file running as a scheduled task in cf admin

Asked by shaggysc96 in ColdFusion Application Server, SendMail Email Server, ColdFusion Studio

Tags: Coldfusion, IE 6, <cfmail>

I am using coldfusion 5 and 7 on another server. I have the code below as a file that will check the undeliverable folder 3 times and try to redeliver the mail before deleting it. Everything looks right to me, (but could not be). I have scheduled it to run in administrator as a scheduled task to run every 5 minutes. The file called cfrespoolprg.cfm and I put it in the CFIDE/scripts folder.
Under administrator in coldfusion I went to schedule task. For the url I put http://66.153.205.3/cfide/scripts/cfrespoolprg.cfm where (66.153.205.3) is the server IP. I put in the uname and password, and hit submit. If I run the task it says, task completed successfully(or something like that) but my emails are staying in the undeliverable folder (there are 2). What could be wrong?
Below is the cfrespoolprg.cfm
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
<!--- program to allow you to reprocess an undeliverable email up to five times before it's permanently deleted off of the server --->
<!--- set to run every hour --> 
 
 
<cfapplication name="MailCheck" sessionmanagement="Yes"
               sessiontimeout="#CreateTimeSpan(0,0,0,1)#"
               applicationtimeout="#CreateTimeSpan(0,1,0,0)#">
 
<!--- ColdFusion's Mail directory --->
<CFSET MailRoot="C:\CFusion\Mail">
 
<!--- Copy the key list form the Application scope --->
<cflock timeout="30" throwontimeout="Yes" type="EXCLUSIVE" scope="APPLICATION">
	<CFPARAM name="Application.EmailKeys" default="">
	<CFIF IsArray(Application.EmailKeys) EQ "No">
		<CFSET Application.EmailKeys=ArrayNew(2)>
	</CFIF>
	<CFSET Keys=Duplicate(Application.EmailKeys)>
</cflock>
 
<!--- Set a "Successfully Sent Flag" so that we know if the email managed to make it through the mail server --->
<CFLOOP index="KeyLoop" from="1" to="#ArrayLen(Keys)#">
	<CFSET Keys[KeyLoop][3]=0>
</CFLOOP>
 
<!--- Get a list of bounced mail --->
<cfdirectory action="LIST" directory="#MailRoot#/UnDelivr" name="Dir">
<CFLOOP query="Dir">
	<CFSET cr=CurrentRow>
	<CFIF Dir.Type EQ "File">
		<!--- Read in the file and generate a unique Hash value from the contents to identify this email from all the others --->
		<cffile action="READBINARY" file="#MailRoot#/UnDelivr/#Dir.Name[cr]#" variable="FileData">
		<CFSET FileHash=Hash(ToBase64(FileData))>
		<!--- If Ok stays zero, it's a new email that we haven't seen before --->
		<CFSET Ok=0>
		<!--- Loop over the bounced emails we've already logged --->
		<CFLOOP index="KeyLoop" from="#ArrayLen(Keys)#" to="1" step="-1">
			<CFIF Keys[KeyLoop][1] EQ FileHash>
				<CFSET Keys[KeyLoop][2]=Keys[KeyLoop][2] + 1>
				<CFIF Keys[KeyLoop][2] GT 5>
					<!--- We've tried to send this email five times already, kill it (or if you wish, move to a different directory) --->
					<cffile action="DELETE" file="#MailRoot#/UnDelivr/#Dir.Name[cr]#">
					<CFSET Jnk=ArrayDeleteAt(Keys,KeyLoop)>
					<CFSET Ok=1>
				<CFELSE>
					<!--- We've tried to send this email five times or less so far, let's try again --->
					<cffile action="MOVE" source="#MailRoot#/UnDelivr/#Dir.Name[cr]#" destination="#MailRoot#/Spool/#Dir.Name[cr]#">
					<CFSET Ok=1>
					<CFSET Keys[KeyLoop][3]=1>
				</CFIF>
			</CFIF>
		</CFLOOP>
		<CFIF Ok EQ 0>
			<!--- It's a new email, let's add it to our list --->
			<CFSET NR=ArrayLen(Keys) + 1>
			<CFSET Keys[NR][1]=FileHash>
			<CFSET Keys[NR][2]=1>
			<CFSET Keys[NR][3]=1>
			<cffile action="MOVE" source="#MailRoot#/UnDelivr/#Dir.Name[cr]#" destination="#MailRoot#/Spool/#Dir.Name[cr]#">
		</CFIF>
	</CFIF>
</CFLOOP>
 
<!--- Purge emails from the array that were successfully sent --->
<CFLOOP index="KeyLoop" from="#ArrayLen(Keys)#" to="1" step="-1">
	<CFIF Keys[KeyLoop][3] EQ 0>
		<CFSET Jnk=ArrayDeleteAt(Keys,KeyLoop)>
	</CFIF>
</CFLOOP>
 
<cflock timeout="30" throwontimeout="Yes" type="EXCLUSIVE" scope="APPLICATION">
	<CFSET Application.EmailKeys=Duplicate(Keys)>
</cflock>
[+][-]01/25/08 01:10 PM, ID: 20746367Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/25/08 01:16 PM, ID: 20746416Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/25/08 01:27 PM, ID: 20746515Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/25/08 01:30 PM, ID: 20746532Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/25/08 01:33 PM, ID: 20746543Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/25/08 01:42 PM, ID: 20746606Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/28/08 06:36 AM, ID: 20759215Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/28/08 07:14 AM, ID: 20759607Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/28/08 09:26 AM, ID: 20761034Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/28/08 09:43 AM, ID: 20761180Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/28/08 10:39 AM, ID: 20761641Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/28/08 10:40 AM, ID: 20761652Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/28/08 10:51 AM, ID: 20761746Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/30/08 03:54 PM, ID: 20782832Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 / EE_QW_2_20070628