CFLib.org – Common Function Library Project

cfMailFactory(mailaction)

Last updated January 7, 2007

Version: 1 | Requires: ColdFusion MX | Library: UtilityLib

 
Rated 0 time(s). Average Rating: 0

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:

view plain print about
<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:

view plain print about
<!---
 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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
30 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson