ColdFusion Muse

Creating an "On Behalf Of" From Address Using Cfmail

Mark Kruger October 25, 2005 6:21 PM Coldfusion Tips and Techniques Comments (4)

If you use MS Outlook and you subscribe to any of the email lists from figleaf.com, you may have noticed the informative way that messages are displayed. The "sender" is identified as the list server but the address of the actual sender is also included with the tag line of "on behalf of". So, if boy@george.com sends a message to list-serve@rollingstone.com, the from would be displayed as list-serv@rollingstone.com on behalf of boy@george.com. It took a while for me and my good friend Tracy Rice figure out how to do this in Coldfusion.

Read More
  • Share:

CFMAIL and SMTP Authentication

Mark Kruger October 14, 2005 11:26 AM Coldfusion Tips and Techniques Comments (3)

It's pretty common these days for mail servers to require SMTP authentication. The problem is that the CFMAIL tag has no place for a username and password when sending mail. Not to worry, you can use the "username:password@mydomain.com" syntax in the "server" attribute of the tag to authenticate. For Example:

<Cfmail server="buffy:catsRcool@mail.buffyscats.com"
         from="info@buffycats.com"
            to="bobbiejoe@hotmail.com"
                  subject="Your cat is on the way">

Thank you for buy from Buffy's Cat.
Your cat will be shipped within 24 hours.
Remember to keep refrigerated until use.

</CFMAIL>

You can also use the same server syntax in the mail server text box in CF admin. If your server doesn't use SMTP but uses "POP before SMTP" you can solve that problem by hitting a mailbox first with CFPOP then sending your mail. Dan Vega has a great explanation of that technique.

  • Share:

Alternating Row Color Tip

Mark Kruger September 27, 2005 6:49 PM Coldfusion Tips and Techniques Comments (7)

Before you read this, if you are a bona fide CSS guru, don't laugh at me. Remember I'm just a Coldfusion code jockey with only a bare minimum of aesthetic sensibility and I see CSS with the same approximate mystery as I see women's obsession with shoe shopping. That being said, this is a neat trick for alternating row colors. You know what I mean - you have this long query that is going to be displayed in tabular HTML. You'd like to alternate each row to make the data stand out and be easier to read.

Read More
  • Share:

IsDefined() Vs. StructKeyExists() - The Nuances of CFMX Structures

Mark Kruger September 8, 2005 6:26 PM Coldfusion MX 7, Coldfusion Tips and Techniques Comments (7)

There's a very interesting post and discussion on Brian Kotek's blog today dealing with the use of the function "isDefined( )" vs "structKeyExists( )". If you've been programming since the days of CF 4.x and "parameterexists()" you'll know that using isDefined() can be a delicate experience at times. It becomes especially tricky in CFMX where the way variables are initiated has changed. In the old days you could have a variable in the variables scope that included a period in the name, and unless you specifically called "structNew()" it would stand as primitive variable in the variables scope. Take this Example:

Read More
  • Share:

Application Variables Part II - Thread Safe Gotcha

Here's a tip on application variables from the inestimably knowledgeable Sean Corfield. In my previous post on Application Variables I used a pretty typical example of how they are initialized. I checked for the existence of a particular application variable. If it did not exist, I would lock and set all the variables. Sean pointed out that this approach is still subject to threading issues. To start with, here's the original example.

Read More
  • Share:

Application Variables On Ice

Getting a handle on Application variables can be difficult. Even folks who know what they are sometimes use them incorrectly. There are 2 common forms of simple application variables (we'll leave the discussion of objects and CFCs for another time). There is the "set once read many" variable. Usually these are "settings" for the application - things like paths and data source names - Application.dsn, or Application.imagePath.

Then there is the "global tally" variable. This is less common, but it is usually some variable that is incremented or updated throughout the life of the application. For example, it might be a variable to track the number of logged in users. This variable is actually set (sometimes frequently) as the application is used. The main thing to remember about an application variable is that it lives beyond the request or session. It's something that is put in place as a variable and stays put for every user of the application. Some call it persistence - but the OO purist pee their pants when they hear that so I will refrain (too bad too, it's a good word for it). Let's focus on that first example of "set once read many".

Read More
  • Share:

The Identity Field part II - a Gotcha

Mark Kruger August 18, 2005 12:26 PM MS SQL Server, Coldfusion Tips and Techniques Comments (4)

This is a follow up to the post titled "Getting the ID field after an Insert". I recently saw someone struggle with this because of an easily made syntax error. Consider this code:

Follow up post on doing this in MS Access.

Read More
  • Share:

Dynamic Output Evaluation between the Pound Signs

Mark Kruger August 15, 2005 3:17 PM Coldfusion Tips and Techniques Comments (3)

Some developers use the "NOT" keyword in a unique fashion. Instead of only using it inside of a logic statement they take advantage of CFMX dynamic pound sign evaluation features to treat NOT like it is a function. This is misleading. NOT is not a function. It is an Operand that affects the logic of a statement. The only reason it seems like a function is that CFMX servers have a nifty feature that allows for you to put expressions between pound signs in output code. For example, if you put #1+3+5+8# in between cfoutput tags on a CFMX server the result would be the number 17 sent to the output buffer. That's nifty all right, but that's not all.

Read More
  • Share: