CFLib.org – Common Function Library Project

cfMailFactory(mailaction)

Last updated January 7, 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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson