CFLib.org – Common Function Library Project

cfMailFactory(mailaction)

Last updated January 07, 2007

author

Jose Diaz

Version: 1 | Requires: CF6 | Library: UtilityLib

Description:
Reset MailSpool and access general mail settings. Currently accepts the following actions: - isSpoolEnable - resetSpool - getServer This can be expanded to utilize any of the serviceFactory settings not just the MailSpoolService.

Return Values:
Returns a string or boolean.

Example:

<cfinclude template="cfMailFactoryUDF.cfm">

<cfset mailAction = cfMailFactory("resetSpool")>

<cfoutput>#mailAction#</cfoutput>

Parameters:

Name Description Required
mailaction One of: isspoolenable,getserver,resetspool Yes

Full UDF Source:

<!---
 Reset MailSpool and access general mail settings.
 
 @param mailaction      One of: isspoolenable,getserver,resetspool (Required)
 @return Returns a string or boolean. 
 @author Jose Diaz (bleachedbug@gmail.com) 
 @version 1, April 9, 2007 
--->
<cffunction name="cfMailFactory" access="public" returntype="string" output=false>
    <cfargument name="mailaction" type="string" required="true"/>
    <cfset var mailItem = "">
    <cfset var factory = "">
    <cfset var mm_service = "">
    <cfset var mm_settings = "">
            
    <!--- Access CF Service Factory --->
    <cfobject action="create" type="java" class="coldfusion.server.ServiceFactory" name="factory"/>

    <!--- Begin Action Checks --->
    <cfswitch expression="#trim(arguments.mailaction)#">

        <cfcase value="isSpoolEnable">
            <cfset mailItem = factory.mailSpoolService.isSpoolEnable()>
        </cfcase>

        <cfcase value="resetSpool">
        
            <cflock name="serviceFactory" type="exclusive" timeout="10">
            <cfscript>
            ms_service = factory.mailspoolservice;
            ms_settings = ms_service.settings;
            </cfscript>
            </cflock>
            
            <cfset mailItem = "Reset Successfull">
        </cfcase>

         <cfcase value="getServer">
          <cfset mailItem = factory.mailSpoolService.getServer()>
        </cfcase>

        <cfdefaultcase>
            <cfthrow message="Invalid mail action passed. Must be resetSpool, getServer, or isSpoolEnable.">
        </cfdefaultcase>

     </cfswitch>

    <cfreturn mailItem />

</cffunction>

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson