Riverwatcher Active Content Environment

RACE Documentation:

MAIL - Sending email using RACE

  • TO - The mail recipient.
  • SUBJECT - The subject of the message.
  • FROM - The sender of the mail.
  • CC - The carbon-copy recipient(s).
  • BCC - The blind carbon-copy recipient(s).
  • RAW - When set, all tabs and carriage returns in the message body are ignored (see below).
The mail tag allows the developer to compose and send an email message from within a RACE script. The body of the message can contain RACE code to dynamically generate the message.

The only required attribute is the TO attribute, which designates the recipient's email address. By default the FROM attribute will be http@[server name]. Multiple addresses may be specified in the TO, CC, and BCC attributes by delimiting each with a comma.

If the mail tag fails for any reason, the RACE variable will contain the error message.

For complete control over the message headers and body, you can specify the RAW attribute. When used, RACE will ignore any tabs and carriage returns in the message body. The body of the tag will be treated as a header until an empty line is encountered, in compliance with the SMTP protocol. You will need to use "\\n" and "\t" to specify carriage returns and tabs, respectively.

Example - Simple message sending
Error: Improperly formatted array or hash.

This sends an email to webmaster@riverwatcher.com from the default sender address, and reports any error that may have occurred.

Example - Sending mail with custom headers

<mail to="webmaster@riverwatcher.com" subject="Please use the mail tag safely!" raw>
X-Processor: RACE 2.10.6b\\n
X-Bounce-To: webmaster@riverwatcher.com\\n
X-Good-Reading: www.owasp.org
Hello RACE developers,\\n
Let's not forget to protect our scripts that use the MAIL tag and do\\n
our part to make the online world spam-free:\\n
- When possible, require some form of user authentication to access\\n
scripts using the mail tag.\\n
- Count the number of times each visitor accesses a mail script, and\\n
have the script warn you if access counts become suspicious.\\n
- Avoid using dynamic TO and FROM attributes, or validate each one before\\n
allowing the mail tag to run.\\n
Thanks and have a good day,\\n

This utilizes the mail tags raw mode for adding custom headers. Note the two carriage returns ( ) right after the headers, as that is required.

Example - Production-level debugging

<if test="<$system.error> != ''">
  <define var="$time"><date format="yyyy-MM-dd hh:mm:ss"></define>
  <define var="@vars"><debug dump="vars" display></define>
  <mail to="developer@domain.tld" from="error@domain.tld" subject="Site Error at <$time>">
Error: <$system.error>

Currently defined variables
<for key="$var" list="(<@vars>)">
  <$var> = <$$var>

Time of error: <$time>

If <$system.error> isn't empty, this will dump the error message, all variables and their values, and the current time into an email, presumably to the site developers or administrators.

RACE Documentation

Copyright 2009 Riverwatcher, Inc. Hosting by Riverwatcher Studios