> What is the best way to handle optional attributes for the
> cfmail tag? I
> have noticed you cannot specify the attribute and then
> leave it blank,
> because the email will be sent to the undeliverable
> directory.

I've never had this experience with the server attribute... what
version of CF is this?

> Here is how we are thinking about doing it:

> <cfsavecontent variable="MailMessage">
>   <cfoutput query="GetCustomer">Dear #FirstName#,
>     Blah blah blah...
>   </cfoutput>
> </cfsavecontent>

> <cfif len(request.emailserver) >
>   <cfmail to="#Email#"
>     from="#request.email#"
>     subject="New #request.storename# Password"
>     server="#request.emailserver#">#MailMessage#</cfmail>
> <cfelse>
>   <cfmail to="#Email#"
>     from="#request.email#"
>     subject="New #request.storename#
>     Password">#MailMessage#</cfmail>
> </cfif>

> How do others handle this situation? Is there a cleaner
> way to handle this,
> because cfmail has many attributes and some are required
> and some are not
> depending on the server configuration.

For my stuff I have a custom tag that wraps around cfmail and gets its
default attributes from a request variable to provide consistent mail
delivery. It looks something like this:

<cfset structAppend(attributes,request.tap.mail,false)>
<cfparam name="attributes.from" type="string">
<cfparam name="attributes.to" type="string">
<cfparam name="attributes.subject" type="string">
<cfparam name="attributes.server" type="string" default="">

<cfif thistag.executionmode is "end">
  <cfmail
    server="#attributes.server#"
    from="#attributes.from#"
    to="#attributes.to#"
    subject="#attributes.subject#"
    ...
  >#thistag.generatedcontent#</cfmail>
  <cfset thistag.generatedcontent = "">
</cfif>

The tag is then called:

<cf_mail
  to="[EMAIL PROTECTED]"
  subject="this si a test">
.... test message ...
</cfmodule>

The From attribute is required, but since it's pre-declared in the
framework's request.tap.mail structure it doesn't need to be specified
in the <cf_mail> tag unless you need to override it -- the same also
applies for the server attribute. It's a convenient way to change the
attributes for outgoing email application-wide. Granted, I don't use
<cf_mail> syntax, I use <cfmodule template="#request.tapi.mail()#">
but that's for an entirely different set of reasons.


s. isaac dealey   954.522.6080
new epoch : isn't it time for a change?

add features without fixtures with
the onTap open source framework

http://www.fusiontap.com
http://coldfusion.sys-con.com/author/4806Dealey.htm




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:213305
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to