Adobe ColdFusion 8

Using ColdFusion with mail servers

Adding e-mail to your ColdFusion applications lets you respond automatically to user requests. You can use e-mail in your ColdFusion applications in many different ways, including the following:

  • Trigger e-mail messages based on users' requests or orders.
  • Allow users to request and receive additional information or documents through e-mail.
  • Confirm customer information based on order entries or updates.
  • Send invoices or reminders, using information pulled from database queries.

ColdFusion offers several ways to integrate e-mail into your applications. To send e-mail, you generally use the Simple Mail Transfer Protocol (SMTP). To receive e-mail, you use the Post Office Protocol (POP) to retrieve e-mail from the mail server. To use e-mail messaging in your ColdFusion applications, you must have access to an SMTP server and/or a valid POP account.

In your ColdFusion application pages, you use the cfmail and cfpop tags to send and receive e-mail, respectively. The following sections describe how to use the ColdFusion e-mail features and show examples of these tags.

How ColdFusion sends mail

The ColdFusion implementation of SMTP mail uses a spooled architecture. If you select to spool mail on the Mail page in the ColdFusion Administrator, when an application page processes a cfmail tag, the messages that are generated are not sent immediately. Instead, they are spooled to disk and processed in the background. This architecture has two advantages:

  • End users of your application are not required to wait for SMTP processing to complete before a page returns to them. This design is especially useful when a user action causes more than a handful of messages to be sent.
  • Messages sent using cfmail are delivered reliably, even in the presence of unanticipated events like power outages or server crashes.

You can set how frequently ColdFusion checks for spooled mail messages on the Mail page in the ColdFusion Administrator. If ColdFusion is extremely busy or has a large existing queue of messages, however, delivery can occur after the spool interval.

Some ColdFusion editions have advanced spooling options that let you fine tune how ColdFusion sends mail. For more information, see Configuring and Administering ColdFusion.

Error logging and undelivered messages

ColdFusion logs all errors that occur during SMTP message processing to the file mail.log in the ColdFusion log directory. The log entries contain the date and time of the error as well as diagnostic information about why the error occurred.

If a message is not delivered because of an error, ColdFusion writes it to this directory:

  • In Windows: \CFusion\Mail\Undelivr
  • On UNIX: /opt/coldfusion/mail/undelivr

The error log entry that corresponds to the undelivered message contains the name of the file written to the UnDelivr (or undelivr) directory.

Note: To have ColdFusion try to resend a message that it could not deliver, move the message file from the Undelivr directory to the Spool directory.

For more information about the mail logging settings in the ColdFusion Administrator, see Configuring and Administering ColdFusion.