Advertisement

01.25.2008 at 07:59AM PST, ID: 23111385 | Points: 500
[x]
Attachment Details

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

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>
Start your free trial to view this solution
Question Stats
Zone: Software
Question Asked By: shaggysc96
Question Asked On: 01.25.2008
Participating Experts: 1
Points: 500
Views: 0
Translate:
Loading Advertisement...
01.25.2008 at 01:10PM PST, ID: 20746367

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.25.2008 at 01:16PM PST, ID: 20746416

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.25.2008 at 01:27PM PST, ID: 20746515

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.25.2008 at 01:30PM PST, ID: 20746532

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.25.2008 at 01:33PM PST, ID: 20746543

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.25.2008 at 01:42PM PST, ID: 20746606

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.28.2008 at 06:36AM PST, ID: 20759215

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.28.2008 at 07:14AM PST, ID: 20759607

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.28.2008 at 09:26AM PST, ID: 20761034

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.28.2008 at 09:43AM PST, ID: 20761180

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.28.2008 at 10:39AM PST, ID: 20761641

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.28.2008 at 10:40AM PST, ID: 20761652

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.28.2008 at 10:51AM PST, ID: 20761746

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.30.2008 at 03:54PM PST, ID: 20782832

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
01.25.2008 at 01:10PM PST, ID: 20746367

Rank: Guru

Have you checked your error logs to see if there are any errors occurring with that script?

Also is there some reason why you decided to put the template in the /cfide/scripts directory? That seems a little unorthodox. I would recommend that you put these kinds of scripts into a separate directory that is not under /cfide/.
 
01.25.2008 at 01:16PM PST, ID: 20746416
at the risk of sounding stupid, where would these error logs be? It was recommended to put in a directory such as cfide.
 
01.25.2008 at 01:27PM PST, ID: 20746515

Rank: Guru

In the logs folder in the coldfusion application root directory, In coldfusion 6 I believe its:
C:\CFusionMX\Logs

in 7 it's

C:\CFusionMX7\Logs

in fact that may be your error right there... you have your code set like this:

<!--- ColdFusion's Mail directory --->
<CFSET MailRoot="C:\CFusion\Mail">

when on the coldfusion 7 server it should probably be like:

<!--- ColdFusion's Mail directory --->
<CFSET MailRoot="C:\CFusionMX7\Mail">


 
01.25.2008 at 01:30PM PST, ID: 20746532
It is set up that way on coldfusion 7, sorry. The code I gave you was how I set it up on coldfusion 5.
 
01.25.2008 at 01:33PM PST, ID: 20746543
Also I did not see anything about the file in the logs. There were 2 I looked through. cfadmin and server.
 
01.25.2008 at 01:42PM PST, ID: 20746606

Rank: Guru

look at the exceptions log and the application log
 
01.28.2008 at 06:36AM PST, ID: 20759215
I did not see anything in the logs indicating an error. In the scheduler logs I have these messages;
"Scheduled task 'respoolmail' for URL request 'http://66.153.205.3/cfide/scripts/cfrespoolprg.cfm' initiated." "Status code for task: 'respoolmail' is '200 Success'" yet there are over 200 messages in the undeliverable folder today. Any suggestions? or other ways to get the undeliverable email redelivered automatically?

 
01.28.2008 at 07:14AM PST, ID: 20759607
It looks like I have found the problem, but now how to  fix it?
The reason most of the emails are being put in the undeliverable folder, from the mail logs, is
"SMTP server replied "No connection to mail server".
I have increased the connection timeout to 75 with the mail server  in cfadministrator.
Anyone know why the SMTP server connection would not always be connected?
And any way possible to fix my problem?
 
01.28.2008 at 09:26AM PST, ID: 20761034

Rank: Guru

There are lots of reasons why you may not be able to connect to your mail server. I would start by checking the settings in the mail section of coldfusion administrator. If those are all correct, I would look at the smtp server configuration and make sure that it is allowing smtp messages to be relayed from the coldfusion server.
 
01.28.2008 at 09:43AM PST, ID: 20761180
IF the SMTP server didn't allow messages to be relayed, wouldn't all of the messages go into the undeliverable folder? They are not all going there, some are being delivered. Any idea as to how to check the smtp server configuration for that?
 
01.28.2008 at 10:39AM PST, ID: 20761641

Rank: Guru

It could be that there is an intermittent problem with the connection between the SMTP server and the CF server.
 
01.28.2008 at 10:40AM PST, ID: 20761652

Rank: Guru

Or perhaps some kind of throttle setting that restricts how many messages are allowed from a certain IP to prevent DOS attacks, or spamming.
 
01.28.2008 at 10:51AM PST, ID: 20761746
ok, thanks. Fixing that would be over my head,back to my original question any ideas on how to make the above file work?
 
01.30.2008 at 03:54PM PST, ID: 20782832

Rank: Guru

if it not throwing any errors then perhaps it is just not scheduled correctly? try adding a little code to the template that logs a timestamp to a file everytime it runs. add this snippet of code to your script on the cf8 server and it will create a log file in the same directory as your script and append a timestamp everytime it runs.
1:
2:
3:
4:
5:
6:
7:
8:
<cfset variables.successFileName = expandPath('emailRetryUndelvr.log') />
<cfif ! fileExists(variables.successFileName)>
	<cfset fileWrite(variables.successFileName, "") />
</cfif>
 
<cfset variables.fileObj = fileOpen(variables.successFileName, "append") />
<cfset fileWriteLine(variables.fileObj, "#now()#") />
<cfset fileClose(variables.fileObj) />
Open in New Window
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628