Every now and then, something goes
wrong when ColdFusion attempts to send an email. Problems can range
from a missing email address in the
to a problem connecting to the SMTP server. Regardless of the cause
of the problem, ColdFusion deals with undeliverable email in a
consistent and simple manner. All undeliverable email messages are
written to temporary files with a .cfmail
extension and saved to a folder on the ColdFusion server called
\undelivr folder is usually located in
To resend a message that has been moved to the \undelivr folder, the temporary file must be moved back to the \spool folder, which is usually located in \cfusionmx\mail\spool. This can be done manually or via ColdFusion. Obviously, using ColdFusion to monitor the \undelivr directory for undelivered mail is more convenient than manually checking the directory every time an email is generated. To do this, you need to create a template that scans the \undelivr folder and schedule it to run at set intervals. Example 13-7 contains a template you can use to scan your \undelivr folder and move any files found back to the \spool folder so that attempts can be made to resend them. Using the Scheduler within the ColdFusion Administrator, the template can be set to run at predetermined intervals.
Example 13-7. CFML template for dealing with undeliverable mail
<!--- Get the mail root directory ---> <cfset MailRoot="#server.ColdFusion.RootDir#\mail"> ...