CFLib.org – Common Function Library Project

cfMailFactory(mailaction)

Last updated January 7, 2007
Download UDF

author

Jose Diaz                                         Jose Diaz

Version: 1 | Requires: ColdFusion MX | 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 Compton Raymond Compton added
structBlend
19 day(s) ago

Duncan Duncan added
IsZIPUK
19 day(s) ago

Todd Sharp Todd Sharp added
getTagContentAll
25 day(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Created by Raymond Camden / Design by Justin Johnson