ColdFusion mail queue stops processing

后端 未结 7 1900
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-31 07:44

Our CF server occasionally stops processing mail. This is problematic, as many of our clients depend on it.

We found suggestions online that mention zero-byte fil

相关标签:
7条回答
  • 2020-12-31 08:28

    There is a bug in Ben Doom's code. Thank you anyway ben, the code is great, and we use it now on one of our servers with CF8 installed, but: if directory (\spool) is empty, the code fails (error: Date value passed to date function DateDiff is unspecified or invalid.) That's because if the query object spool is empty (spool.recordcount EQ 0), the datediff function produces an error.

    we used this now:

    <!--- check if request for this page is local to prevent "webusers" to request this page over and over, only localhost (server) can get it e.g. by cf scheduled tasks--->
    <cfsetting requesttimeout="30000">
    <cfset who = CGI.SERVER_NAME>
    <cfif find("localhost",who) LT 1>
        security restriction, access denied.
        <cfabort>
    </cfif> 
    
    <!--- get spool directory info --->
    <cfdirectory action="list" directory="C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion\Mail\Spool\" name="spool" sort="datelastmodified">
    <cfset restart = 0>
    <cfif spool.recordcount GT 0><!--- content there? --->
        <cfif datediff('n', spool.datelastmodified, now()) gt 120>
            <cfset restart = 1>
        </cfif>
    </cfif>
    <cfif restart><!--- restart --->
        <cfsavecontent variable="liste">
            <cfdump var="#list#">
        </cfsavecontent>    
        <!--- info --->
        <cfmail to="x@y.com" subject="cfmailqueue restarted by daemon" server="xxx" port="25"  from="xxxx" username="xxxx" password="xxx" replyto="xxxx">
        1/2 action: ...try to restart. Send another mail if succeeded!
        #now()#
    
        Mails:
        #liste#
        </cfmail>
    
        <cfset sFactory = CreateObject("java","coldfusion.server.ServiceFactory")>
        <cfset MailSpoolService = sFactory.mailSpoolService>
        <cfset MailSpoolService.stop()>
        <cfset MailSpoolService.start()>
    
        <!--- info --->
        <cfmail to="x@y.com" subject="cfmailqueue restarted by daemon" server="xxx" port="25"  from="xxxx" username="xxxx" password="xxx" replyto="xxxx">
        2/2 action: ...succeeded!
        #now()#
        </cfmail>
    
    </cfif>
    
    0 讨论(0)
提交回复
热议问题