Home > CFWheels, ColdFusion > Learning CFWheels — Debugging

Learning CFWheels — Debugging

February 24th, 2010

CFWheels has some great documentation and examples, but there is still a small learning curve. As you are getting going, it helps to have a few debugging tips. So, keep reading …

On the CFWheels Google Group, Cathy recently asked about the sendEmail() function. This is a pretty good example to show you some debugging tips.

sendEmail() wraps the cfmail tag. Here’s some more information:

CFWheels on sending email.

This all looks pretty straightforward, but what do you do if it’s not working?

First, setup a test view page. Go to the Wheels views folder and add a new folder called test. Then create a new file called index.cfm in the test folder. The path should be /views/test/index.cfm.

In the index.cfm file you just create, put the following:

1
2
3
4
5
6
<cfset
  set(functionName="sendEmail",
  server="yourServer",
  username="yourUsername",
  password="yourPassword")
>

This will trigger the sendEmail() function. You can access the test page at http://localhost/index.cfm/test. But, if you go to this page, you’ll get an error because we didn’t create myemailtemplate, yet. So, make another CFM page in /views/test/ called myemailtemplate.cfm. The content can be anything you want. Something like “Test email” is fine.

Wheels knows you are in the Test controller, so it looks for templates in the /views/test folder. Wait a minute! You never said anything about creating a controller. That’s one of the cool things about Wheels. Even without a controller, it will still show you the view page, and things still work!

Now, go back to the test page at http://localhost/index.cfm/test. If everything is working, you should get an email message. If it’s not working, you can put other stuff in your test page. Try these out:

  • <cfdump var=”#params#”> will show you the params structure with your actions, controller, data you’re passing, etc.
  • <cfdump var=”#wheels#”> will show information on your filters.
  • <cfdump var=”#application.wheels#”> will show all the wheels settings, functions, routes — All kinds of cool things.

Now sendEmail() is a little trickier. It uses ColdFusion’s <cfmail> tag. Put this in your /views/test/index.cfm file:

1
2
3
4
5
<cfmail from="me@mydomain.com"
   to="me@mydomain.com"
   subject="Test Message">
  This is a test
</cfmail>

If this won’t work, then it’s your server configuration, not Wheels. You may have to specify your server name or login information. That’s pretty easy, too. Just put the following in your config/settings:

1
2
3
4
5
6
<cfset
  set(functionName="sendEmail",
  server="yourServer",
  username="yourUsername",
  password="yourPassword")
>

I hope this helps!

Clarke Bishop CFWheels, ColdFusion

  1. No comments yet.
  1. No trackbacks yet.