Whatever message this page gives is out now! Go check it out!
<cfmail
from = "e-mail address"
to = "comma-delimited list"
bcc = "comma-delimited list"
cc = "comma-delimited list"
charset = "character encoding"
debug = "yes|no"
failto = "e-mail address"
group = "query column"
groupcasesensitive = "yes|no"
idnaversion="IDNA encoding"
mailerid = "header id"
maxrows = "integer"
mimeattach = "path"
password = "string"
port = "integer"
priority = "integer or string priority level"
query = "query name"
remove = "yes|no"
replyto = "e-mail address"
server = "SMTP server address"
spoolenable = "yes|no"
startrow = "query row number"
subject = "string"
timeout = "number of seconds"
type = "mime type"
username = "SMTP user ID"
useSSL = "yes|no"
useTLS = "yes|no"
wraptext = "column number"
sign = "true|false"
keystore = "location of keystore"
keystorepassword = "password of keystore"
keyalias = "alias of key"
keypassword = "password for private key"
encrypt "true|false"
recipientcert = <path to the public key cert>
encryptionalgorithm = "DES_EDE3_CBC, RC2_CBC, AES128_CBC, AES192_CBC, AES256_CBC">
(Optional) Mail message body and/or cfmailparam tags
</cfmail>Attribute | Req/Opt | Default | Description |
bcc | Optional | Addresses to which to copy the message, without listing them in the message header. To specify multiple addresses, separate the addresses with commas. | |
cc | Optional | Addresses to which to copy the message. To specify multiple addresses, separate the address with commas. | |
charset | Optional | Character encoding selected in ColdFusion Administrator Mail page; utf-8 | Character encoding of the mail message, including the headers. The following list includes commonly used values:
|
debug | Optional | no |
|
failto | Optional | Address to which mailing systems must send delivery failure notifications. Sets the mail envelope reverse-path value. | |
from | Required | E-mail message sender:
| |
to | Required | Message recipient e-mail addresses:
| |
subject | Required | Message subject. Can be dynamically generated. For example, to send messages that give customers status updates: "Status of Order Number #Order_ID#". | |
group | Optional | CurrentRow | Query column to use when you group sets of records to send as a message. For example, to send a set of billing statements to a customer, group on "Customer_ID." Case-sensitive. Eliminates adjacent duplicates when data is sorted by the specified field. |
groupcasesensitive | Optional | No | Boolean. Whether to consider case when using the group attribute. To group on case-sensitive records, set this attribute to Yes. |
| idnaversion | Optional | 2008 | Choose the IDNA encoding to be applied. If no IDNAversion attribute is specified, then the encoding specified in the JVM flag will be applied. If idnaversion is specified, then the respective encoding will be applied. |
keyalias | Optional | Alias of the key with which the certificate and private key are stored in the keystore. If it is not specified, the first entry in the keystore is chosen as the alias. | |
keypassword | Optional | Password for your private key. If not specified, the keystorepassword is used. | |
keystore | Optional | The location of the keystore file, for example, C:\OpenSSL\bin\keystore.jks. | |
keystorepassword | Optional | The password of the keystore. This is stored in ColdFusion configuration files. | |
mailerid | Optional | ColdFusion Application Server | Mailer ID to be passed in X-Mailer SMTP header, which identifies the mailer application. |
maxrows | Optional | Maximum number of messages to send when looping over a query. | |
mimeattach | Optional | Path of the on-disk or in-memory file to attach to message. Attached file is MIME-encoded. ColdFusion attempts to determine the MIME type of the file; use the cfmailparam tag to send an attachment and specify the MIME type. | |
password | Optional | A password to send to SMTP servers that require authentication. Requires a username attribute. | |
port | Optional | TCP/IP port on which SMTP server listens for requests (normally 25). A value here overrides the Administrator. | |
priority | Optional | 3 | The message priority level. Can be one of the following values:
|
query | Optional | Name of cfquery from which to draw data for messages. Use this attribute to send more than one message, or to send query results within a message. | |
remove | Optional | no | If yes, ColdFusion removes attachment files (if any) after the mail is successfully delivered. |
replyto | Optional | Addresses to which the recipient is directed to send replies. | |
server | Optional | SMTP server address, or (Enterprise edition only) a comma-delimited list of server addresses, to use for sending messages. At least one server must be specified here or in the ColdFusion Administrator. A value here overrides the Administrator. A value that includes a port specification overrides the port attribute. For details, see Usage. | |
sign | Digitally signs the mail. If set to true, all messages that you send will have digital signature. | ||
spoolenable | Optional | Whether to spool mail or always send it Immediately. Overrides the ColdFusion Administrator Spool mail messages to disk for delivery setting.
| |
startrow | Optional | 1 | Row in a query to start from. |
timeout | Optional | Number of seconds to wait before timing out connection to SMTP server. A value here overrides the Administrator. | |
type | Optional | text/plain | MIME type of the message. Can be a valid MIME media type or one of the following:
|
username | Optional | A user name to send to SMTP servers that require authentication. Requires a password attribute. | |
useSSL | Optional | Whether to use Secure Sockets Layer. | |
useTLS | Optional | Whether to use Transport Level Security. | |
wraptext | Optional | Do not wrap text | The maximum line length, in characters of the mail text. If a line has more than the specified number of characters, replaces the last white space character, such as a tab or space, preceding the specified position with a line break. If there are no white space characters, inserts a line break at the specified position. A common value for this attribute is 72. |
| encrypt | Optional | false | If the Email should be encrypted. |
| recipientcert | Optional | false | The path to the public key certificate of the recipient. |
| encryptionalgorithm | Optional | The encryption algorithm to use. The valid algorithms are:
The encryption support is provided through S/MIME. |
Format | Example |
user (server)company.com | |
<user@server> | <rsmith@company.com> |
DisplayName <user@server> | Rob Smith <rsmith@company.com> |
"DisplayName" <user@server> | "Rob Smith" <rsmith@company.com> |
user@server (DisplayName) | rsmith@company.com (Rob Smith) |
[user:password@]server[:port],[user:password@]server[:port],....server=mail.myco.com,mail_admin:adm2qzf@mail2.myco.com:24<cfmail from="Sender@Company.com" server="sendmail.myCo.com" sign="true" keystore="C:\OpenSSL\bin\hello.jks" keystorepassword="digital" to="Recepient@Company.com" keyalias="crypto" keypassword="signature" subject="Mail with Digital Signature"><h3>cfmail Example</h3>
<!--- Delete the surrounding comments to use this example.
<cfif IsDefined("form.mailto")>
<cfif form.mailto is not "" AND form.mailfrom is not "" AND form.Subject is not "">
<cfmail to = "#form.mailto#" from = "#form.mailFrom#" subject = "#form.subject#">
This message was sent by an automatic mailer built with cfmail:
= = = = = = = = = = = = = = = = = = = = = = = = = = =
#form.body#
</cfmail>
<h3>Thank you</h3>
<p>Thank you, <cfoutput>#mailfrom#: your message, #subject#, has been sent to
#mailto#</cfoutput>.</p>
</cfif>
</cfif>
<p>
<form action = "cfmail.cfm" method="POST">
<pre>
TO: <input type = "Text" name = "MailTo">
FROM: <input type = "Text" name = "MailFrom">
SUBJECT: <input type = "Text" name = "Subject">
<hr>
MESSAGE BODY:
<textarea name ="body" cols="40" rows="5" wrap="virtual"></textarea>
</pre>
<!--- Establish required fields. --->
<input type = "hidden" name = "MailTo_required" value = "You must enter a recipient">
<input type = "hidden" name = "MailFrom_required" value = "You must enter a sender">
<input type = "hidden" name = "Subject_required" value = "You must enter a subject">
<input type = "hidden" name = "Body_required" value = "You must enter some text">
<p><input type = "Submit" name = ""></p>
</p>
</form><cfset path = GetDirectoryFromPath(getCurrentTemplatePath())>
<cfset algorithms = "DES_EDE3_CBC,RC2_CBC,AES128_CBC,AES192_CBC,AES256_CBC">
<cfloop index="algo" list="#algorithms#">
<cfmail to="joe@work.com" from="bob@work.com"
subject="Sending a mail with the encryption algo : #algo#"
sign ="false"
encrypt="true"
ENCRYPTIONALGORITHM = "#algo#"
recipientcert="#path#cert.p7c" >
This message is encrypted using the algorithm : #algo#.
</cfmail>
</cfloop><cfprocessingdirective pageencoding="utf-8">
<cfmail to="sample@example.com"
from="test@example.com"
username="username"
password="password"
server="localhost"
subject="hello"
debug="true"
idnaversion="2003">
Hello World !
</cfmail><cfscript>
// Simulate new user registration (in production, this comes from form/database)
newUser = {
firstName: "John",
lastName: "Smith",
email: "john.smith@example.com",
username: "jsmith",
registrationDate: now(),
accountType: "Premium"
};
// Configuration
fromEmail = "welcome@mycompany.com";
fromName = "MyCompany Team";
companyName = "MyCompany";
websiteURL = "https://www.mycompany.com";
loginURL = "https://www.mycompany.com/login";
// Flag to control email sending (set to true to actually send)
sendEmail = isDefined("url.send") AND url.send EQ "true";
</cfscript>
<h2>📧 Welcome Email System</h2>
<!--- Display User Information --->
<div style="background: ##e3f2fd; border: 2px solid ##2196f3; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="margin-top: 0;">New User Registration</h3>
<cfoutput>
<p><strong>Name:</strong> #newUser.firstName# #newUser.lastName#</p>
<p><strong>Email:</strong> #newUser.email#</p>
<p><strong>Username:</strong> #newUser.username#</p>
<p><strong>Account Type:</strong> #newUser.accountType#</p>
<p><strong>Registration Date:</strong> #dateTimeFormat(newUser.registrationDate, "yyyy-mm-dd HH:nn:ss")#</p>
</cfoutput>
</div>
<!--- Send Welcome Email --->
<cfif sendEmail>
<cftry>
<!--- Send HTML Welcome Email --->
<cfmail
to="#newUser.email#"
from="#fromEmail#"
subject="Welcome to #companyName#, #newUser.firstName#!"
type="html"
server="localhost"
port="25">
<!--- HTML Email Content --->
<html>
<head>
<style>
body { font-family: Arial, sans-serif; line-height: 1.6; color: ##333; }
.container { max-width: 600px; margin: 0 auto; }
.header { background: ##2196f3; color: white; padding: 30px; text-align: center; }
.content { padding: 30px; background: ##f9f9f9; }
.button { display: inline-block; padding: 15px 30px; background: ##4caf50; color: white; text-decoration: none; border-radius: 5px; margin: 20px 0; }
.info-box { background: ##e3f2fd; padding: 15px; border-left: 4px solid ##2196f3; margin: 20px 0; }
.footer { background: ##333; color: white; padding: 20px; text-align: center; font-size: 12px; }
</style>
</head>
<body>
<cfoutput>
<div class="container">
<!--- Header --->
<div class="header">
<h1 style="margin: 0;">Welcome to #companyName#!</h1>
<p style="margin: 10px 0 0 0;">We're excited to have you on board</p>
</div>
<!--- Content --->
<div class="content">
<h2>Hello #newUser.firstName#,</h2>
<p>Thank you for creating your #companyName# account! Your registration was successful and you're all set to get started.</p>
<!--- Account Details --->
<div class="info-box">
<h3 style="margin-top: 0;">Your Account Details</h3>
<p><strong>Username:</strong> #newUser.username#</p>
<p><strong>Email:</strong> #newUser.email#</p>
<p><strong>Account Type:</strong> #newUser.accountType#</p>
<p><strong>Registration Date:</strong> #dateFormat(newUser.registrationDate, "mmmm d, yyyy")#</p>
</div>
<!--- Getting Started --->
<h3>Getting Started</h3>
<p>Here are some things you can do right away:</p>
<ul>
<li>Complete your profile</li>
<li>Explore our features</li>
<li>Connect with other users</li>
<li>Check out our help center</li>
</ul>
<!--- Call to Action --->
<div style="text-align: center;">
<a href="#loginURL#" class="button">Log In to Your Account</a>
</div>
<!--- Support Info --->
<p>If you have any questions, our support team is here to help. Just reply to this email or visit our help center.</p>
<p>Best regards,<br>
<strong>The #companyName# Team</strong></p>
</div>
<!--- Footer --->
<div class="footer">
<p>© #year(now())# #companyName#. All rights reserved.</p>
<p>#websiteURL#</p>
<p>This email was sent to #newUser.email# because you registered for an account.</p>
</div>
</div>
</cfoutput>
</body>
</html>
</cfmail>
<!--- Success Message --->
<div style="background: ##e8f5e9; border: 2px solid ##4caf50; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="color: green; margin-top: 0;">✓ Welcome Email Sent Successfully!</h3>
<cfoutput>
<p><strong>Recipient:</strong> #newUser.email#</p>
<p><strong>Subject:</strong> Welcome to #companyName#, #newUser.firstName#!</p>
<p><strong>Sent:</strong> #dateTimeFormat(now(), "yyyy-mm-dd HH:nn:ss")#</p>
</cfoutput>
</div>
<!--- Log email activity (in production, save to database) --->
<cflog
file="email_activity"
type="information"
text="Welcome email sent to #newUser.email# (User: #newUser.username#)">
<cfcatch type="any">
<!--- Error Handling --->
<div style="background: ##ffebee; border: 2px solid ##f44336; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="color: red; margin-top: 0;">✗ Email Sending Failed</h3>
<p><strong>Error:</strong> #cfcatch.message#</p>
<p><strong>Detail:</strong> #cfcatch.detail#</p>
<p><strong>Type:</strong> #cfcatch.type#</p>
</div>
<!--- Log error --->
<cflog
file="email_errors"
type="error"
text="Failed to send welcome email to #newUser.email#: #cfcatch.message#">
</cfcatch>
</cftry>
<cfelse>
<!--- Email Preview --->
<div style="background: ##fff3e0; border: 2px solid ##ff9800; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="margin-top: 0;">Email Preview Mode</h3>
<p>Email is ready to send but not sent yet. Click "Send Email" below to actually send.</p>
<p><a href="?send=true" style="padding: 12px 30px; background: ##4caf50; color: white; text-decoration: none; border-radius: 5px; display: inline-block; margin-top: 10px;">
Send Welcome Email
</a></p>
</div>
</cfif>
<!--- Email Content Preview --->
<h3>Email Content Preview</h3>
<div style="background: white; border: 2px solid ##ddd; padding: 20px; margin: 20px 0; border-radius: 5px;">
<!--- Header --->
<div style="background: ##2196f3; color: white; padding: 30px; text-align: center; border-radius: 5px 5px 0 0;">
<cfoutput>
<h1 style="margin: 0;">Welcome to #companyName#!</h1>
<p style="margin: 10px 0 0 0;">We're excited to have you on board</p>
</cfoutput>
</div>
<!--- Content --->
<div style="padding: 30px; background: ##f9f9f9;">
<cfoutput>
<h2>Hello #newUser.firstName#,</h2>
<p>Thank you for creating your #companyName# account! Your registration was successful and you're all set to get started.</p>
<div style="background: ##e3f2fd; padding: 15px; border-left: 4px solid ##2196f3; margin: 20px 0;">
<h3 style="margin-top: 0;">Your Account Details</h3>
<p><strong>Username:</strong> #newUser.username#</p>
<p><strong>Email:</strong> #newUser.email#</p>
<p><strong>Account Type:</strong> #newUser.accountType#</p>
</div>
<h3>Getting Started</h3>
<ul>
<li>Complete your profile</li>
<li>Explore our features</li>
<li>Connect with other users</li>
</ul>
<div style="text-align: center; margin: 30px 0;">
<a href="#loginURL#" style="display: inline-block; padding: 15px 30px; background: ##4caf50; color: white; text-decoration: none; border-radius: 5px;">
Log In to Your Account
</a>
</div>
<p>Best regards,<br>
<strong>The #companyName# Team</strong></p>
</cfoutput>
</div>
<!--- Footer --->
<div style="background: ##333; color: white; padding: 20px; text-align: center; font-size: 12px; border-radius: 0 0 5px 5px;">
<cfoutput>
<p>© #year(now())# #companyName#. All rights reserved.</p>
</cfoutput>
</div>
</div><cfscript>
// Simulate password reset request
userEmail = "john.smith@example.com";
userName = "John Smith";
// Generate secure reset token (in production, use more secure method)
resetToken = createUUID();
tokenExpiration = dateAdd("h", 24, now()); // Token expires in 24 hours
// Configuration
fromEmail = "security@mycompany.com";
companyName = "MyCompany";
resetURL = "https://www.mycompany.com/reset-password?token=" & resetToken;
// In production: Store token in database with user ID and expiration
// INSERT INTO password_resets (user_email, token, expires_at, created_at)
sendEmail = isDefined("url.send") AND url.send EQ "true";
</cfscript>
<h2>🔐 Password Reset System</h2>
<div style="background: ##fff3e0; border: 2px solid ##ff9800; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="margin-top: 0;">Password Reset Request</h3>
<cfoutput>
<p><strong>Email:</strong> #userEmail#</p>
<p><strong>User:</strong> #userName#</p>
<p><strong>Reset Token:</strong> <code style="background: white; padding: 5px;">#resetToken#</code></p>
<p><strong>Token Expires:</strong> #dateTimeFormat(tokenExpiration, "yyyy-mm-dd HH:nn:ss")#
(in #dateDiff("h", now(), tokenExpiration)# hours)</p>
</cfoutput>
</div>
<cfif sendEmail>
<cftry>
<!--- Send Password Reset Email --->
<cfmail
to="#userEmail#"
from="#fromEmail#"
subject="Password Reset Request - #companyName#"
type="html">
<html>
<head>
<style>
body { font-family: Arial, sans-serif; line-height: 1.6; color: ##333; }
.container { max-width: 600px; margin: 0 auto; background: ##f9f9f9; }
.header { background: ##ff9800; color: white; padding: 30px; text-align: center; }
.content { padding: 30px; background: white; }
.button { display: inline-block; padding: 15px 30px; background: ##4caf50; color: white; text-decoration: none; border-radius: 5px; margin: 20px 0; font-weight: bold; }
.warning { background: ##ffebee; border-left: 4px solid ##f44336; padding: 15px; margin: 20px 0; }
.info { background: ##e3f2fd; border-left: 4px solid ##2196f3; padding: 15px; margin: 20px 0; }
.footer { background: ##333; color: ##999; padding: 20px; text-align: center; font-size: 12px; }
</style>
</head>
<body>
<cfoutput>
<div class="container">
<div class="header">
<h1 style="margin: 0;">🔐 Password Reset Request</h1>
</div>
<div class="content">
<h2>Hello #userName#,</h2>
<p>We received a request to reset your password for your #companyName# account.</p>
<p>Click the button below to reset your password:</p>
<div style="text-align: center;">
<a href="#resetURL#" class="button">Reset Your Password</a>
</div>
<div class="info">
<p style="margin: 0;"><strong>ℹ️ Important Information:</strong></p>
<ul style="margin: 10px 0;">
<li>This link will expire in <strong>24 hours</strong></li>
<li>The link can only be used once</li>
<li>Your current password will remain active until you set a new one</li>
</ul>
</div>
<p>If the button doesn't work, copy and paste this link into your browser:</p>
<p style="background: ##f5f5f5; padding: 10px; word-break: break-all; font-size: 12px;">
#resetURL#
</p>
<div class="warning">
<p style="margin: 0;"><strong>⚠️ Security Warning:</strong></p>
<ul style="margin: 10px 0;">
<li>If you didn't request this reset, please ignore this email</li>
<li>Your password will not change unless you click the link</li>
<li>Never share this link with anyone</li>
<li>Contact support if you have concerns about your account security</li>
</ul>
</div>
<p>Best regards,<br>
<strong>#companyName# Security Team</strong></p>
</div>
<div class="footer">
<p>This is an automated security email from #companyName#.</p>
<p>Request Time: #dateTimeFormat(now(), "yyyy-mm-dd HH:nn:ss")# UTC</p>
</div>
</div>
</cfoutput>
</body>
</html>
</cfmail>
<div style="background: ##e8f5e9; border: 2px solid ##4caf50; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="color: green; margin-top: 0;">✓ Password Reset Email Sent!</h3>
<cfoutput>
<p><strong>Sent to:</strong> #userEmail#</p>
<p><strong>Token:</strong> #resetToken#</p>
<p><strong>Expires:</strong> #dateTimeFormat(tokenExpiration, "yyyy-mm-dd HH:nn:ss")#</p>
</cfoutput>
</div>
<cflog file="password_resets" type="information"
text="Password reset email sent to #userEmail# - Token: #resetToken#">
<cfcatch type="any">
<div style="background: ##ffebee; border: 2px solid ##f44336; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="color: red; margin-top: 0;">✗ Failed to Send Reset Email</h3>
<p><strong>Error:</strong> #cfcatch.message#</p>
</div>
<cflog file="email_errors" type="error"
text="Failed password reset email to #userEmail#: #cfcatch.message#">
</cfcatch>
</cftry>
<cfelse>
<p><a href="?send=true" style="padding: 12px 30px; background: ##ff9800; color: white; text-decoration: none; border-radius: 5px; display: inline-block;">
Send Password Reset Email
</a></p>
</cfif><!---
Use Case 3: Order Confirmation Receipt
This demonstrates sending order confirmation emails with details
--->
<cfscript>
// Simulate order data
order = {
orderID: "ORD-2024-0001234",
orderDate: now(),
customerName: "John Smith",
customerEmail: "john.smith@example.com",
shippingAddress: "123 Main Street, Boston, MA 02101",
trackingNumber: "1Z999AA10123456784",
items: [
{name: "Wireless Mouse", quantity: 2, unitPrice: 29.99, total: 59.98},
{name: "USB-C Cable (6ft)", quantity: 3, unitPrice: 12.99, total: 38.97},
{name: "Laptop Stand", quantity: 1, unitPrice: 49.99, total: 49.99}
],
subtotal: 148.94,
tax: 11.92,
shipping: 8.99,
total: 169.85,
paymentMethod: "Visa ending in 4242"
};
sendEmail = isDefined("url.send") AND url.send EQ "true";
</cfscript>
<h2>📦 Order Confirmation System</h2>
<!--- Display Order Information --->
<div style="background: ##e3f2fd; border: 2px solid ##2196f3; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="margin-top: 0;">Order Information</h3>
<cfoutput>
<p><strong>Order ID:</strong> #order.orderID#</p>
<p><strong>Customer:</strong> #order.customerName#</p>
<p><strong>Email:</strong> #order.customerEmail#</p>
<p><strong>Order Date:</strong> #dateTimeFormat(order.orderDate, "yyyy-mm-dd HH:nn:ss")#</p>
<p><strong>Total Amount:</strong> <span style="font-size: 24px; color: ##4caf50; font-weight: bold;">$#numberFormat(order.total, "0.00")#</span></p>
</cfoutput>
</div>
<!--- Order Items Table --->
<h3>Order Items</h3>
<table style="width: 100%; border-collapse: collapse; margin: 20px 0; background: white;">
<thead>
<tr style="background: ##2196f3; color: white;">
<th style="padding: 12px; text-align: left;">Item</th>
<th style="padding: 12px; text-align: center;">Quantity</th>
<th style="padding: 12px; text-align: right;">Unit Price</th>
<th style="padding: 12px; text-align: right;">Total</th>
</tr>
</thead>
<tbody>
<cfloop array="#order.items#" index="item">
<cfoutput>
<tr>
<td style="padding: 10px; border: 1px solid ##ddd;">#item.name#</td>
<td style="padding: 10px; border: 1px solid ##ddd; text-align: center;">#item.quantity#</td>
<td style="padding: 10px; border: 1px solid ##ddd; text-align: right;">$#numberFormat(item.unitPrice, "0.00")#</td>
<td style="padding: 10px; border: 1px solid ##ddd; text-align: right; font-weight: bold;">$#numberFormat(item.total, "0.00")#</td>
</tr>
</cfoutput>
</cfloop>
</tbody>
<tfoot>
<cfoutput>
<tr>
<td colspan="3" style="padding: 10px; border: 1px solid ##ddd; text-align: right;"><strong>Subtotal:</strong></td>
<td style="padding: 10px; border: 1px solid ##ddd; text-align: right;">$#numberFormat(order.subtotal, "0.00")#</td>
</tr>
<tr>
<td colspan="3" style="padding: 10px; border: 1px solid ##ddd; text-align: right;"><strong>Tax:</strong></td>
<td style="padding: 10px; border: 1px solid ##ddd; text-align: right;">$#numberFormat(order.tax, "0.00")#</td>
</tr>
<tr>
<td colspan="3" style="padding: 10px; border: 1px solid ##ddd; text-align: right;"><strong>Shipping:</strong></td>
<td style="padding: 10px; border: 1px solid ##ddd; text-align: right;">$#numberFormat(order.shipping, "0.00")#</td>
</tr>
<tr style="background: ##f5f5f5;">
<td colspan="3" style="padding: 15px; border: 1px solid ##ddd; text-align: right; font-size: 18px;"><strong>TOTAL:</strong></td>
<td style="padding: 15px; border: 1px solid ##ddd; text-align: right; font-size: 18px; color: ##4caf50; font-weight: bold;">$#numberFormat(order.total, "0.00")#</td>
</tr>
</cfoutput>
</tfoot>
</table>
<!--- Shipping Information --->
<div style="background: white; border: 1px solid ##ddd; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="margin-top: 0;">Shipping & Payment</h3>
<cfoutput>
<p><strong>Shipping Address:</strong><br>#order.shippingAddress#</p>
<p><strong>Tracking Number:</strong> #order.trackingNumber#</p>
<p><strong>Payment Method:</strong> #order.paymentMethod#</p>
</cfoutput>
</div>
<cfif sendEmail>
<cftry>
<cfmail
to="#order.customerEmail#"
from="orders@mycompany.com"
subject="Order Confirmation - #order.orderID#"
type="html">
<html>
<body style="font-family: Arial; margin: 0; padding: 20px; background: ##f5f5f5;">
<cfoutput>
<div style="max-width: 600px; margin: 0 auto; background: white;">
<div style="background: ##4caf50; color: white; padding: 30px; text-align: center;">
<h1 style="margin: 0;">✓ Order Confirmed!</h1>
<p style="margin: 10px 0 0 0;">Thank you for your purchase</p>
</div>
<div style="padding: 30px;">
<p>Hi #order.customerName#,</p>
<p>Your order has been confirmed and will be shipped soon.</p>
<div style="background: ##e3f2fd; padding: 15px; margin: 20px 0;">
<p style="margin: 0;"><strong>Order Number:</strong> #order.orderID#</p>
<p style="margin: 5px 0 0 0;"><strong>Order Date:</strong> #dateFormat(order.orderDate, "mmmm d, yyyy")#</p>
</div>
<h3>Order Details</h3>
<table style="width: 100%; border-collapse: collapse;">
<thead>
<tr style="background: ##f5f5f5;">
<th style="padding: 10px; text-align: left; border-bottom: 2px solid ##ddd;">Item</th>
<th style="padding: 10px; text-align: center; border-bottom: 2px solid ##ddd;">Qty</th>
<th style="padding: 10px; text-align: right; border-bottom: 2px solid ##ddd;">Price</th>
<th style="padding: 10px; text-align: right; border-bottom: 2px solid ##ddd;">Total</th>
</tr>
</thead>
<tbody>
<cfloop array="#order.items#" index="item">
<tr>
<td style="padding: 10px; border-bottom: 1px solid ##eee;">#item.name#</td>
<td style="padding: 10px; text-align: center; border-bottom: 1px solid ##eee;">#item.quantity#</td>
<td style="padding: 10px; text-align: right; border-bottom: 1px solid ##eee;">$#numberFormat(item.unitPrice, "0.00")#</td>
<td style="padding: 10px; text-align: right; border-bottom: 1px solid ##eee;">$#numberFormat(item.total, "0.00")#</td>
</tr>
</cfloop>
</tbody>
<tfoot>
<tr>
<td colspan="3" style="padding: 10px; text-align: right;">Subtotal:</td>
<td style="padding: 10px; text-align: right;">$#numberFormat(order.subtotal, "0.00")#</td>
</tr>
<tr>
<td colspan="3" style="padding: 10px; text-align: right;">Tax:</td>
<td style="padding: 10px; text-align: right;">$#numberFormat(order.tax, "0.00")#</td>
</tr>
<tr>
<td colspan="3" style="padding: 10px; text-align: right;">Shipping:</td>
<td style="padding: 10px; text-align: right;">$#numberFormat(order.shipping, "0.00")#</td>
</tr>
<tr style="background: ##f5f5f5; font-weight: bold; font-size: 16px;">
<td colspan="3" style="padding: 15px; text-align: right;">TOTAL:</td>
<td style="padding: 15px; text-align: right;">$#numberFormat(order.total, "0.00")#</td>
</tr>
</tfoot>
</table>
<h3>Shipping Information</h3>
<p><strong>Delivery Address:</strong><br>#order.shippingAddress#</p>
<p><strong>Tracking Number:</strong> #order.trackingNumber#</p>
<h3>Payment Method</h3>
<p>#order.paymentMethod#</p>
<div style="text-align: center; margin: 30px 0;">
<a href="https://www.mycompany.com/track?order=#order.orderID#" style="display: inline-block; padding: 15px 30px; background: ##2196f3; color: white; text-decoration: none; border-radius: 5px;">
Track Your Order
</a>
</div>
<p>Questions? Contact us at support@mycompany.com</p>
</div>
</div>
</cfoutput>
</body>
</html>
</cfmail>
<div style="background: ##e8f5e9; border: 2px solid ##4caf50; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="color: green; margin-top: 0;">✓ Order Confirmation Email Sent!</h3>
<cfoutput>
<p><strong>Sent to:</strong> #order.customerEmail#</p>
<p><strong>Subject:</strong> Order Confirmation - #order.orderID#</p>
<p><strong>Sent at:</strong> #dateTimeFormat(now(), "yyyy-mm-dd HH:nn:ss")#</p>
</cfoutput>
</div>
<cflog file="order_emails" type="information"
text="Order confirmation sent: #order.orderID# to #order.customerEmail#">
<cfcatch type="any">
<div style="background: ##ffebee; border: 2px solid ##f44336; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="color: red; margin-top: 0;">✗ Email Sending Failed</h3>
<p><strong>Error:</strong> #cfcatch.message#</p>
<p><strong>Detail:</strong> #cfcatch.detail#</p>
</div>
<cflog file="email_errors" type="error"
text="Failed to send order confirmation for #order.orderID#: #cfcatch.message#">
</cfcatch>
</cftry>
<cfelse>
<!--- Send Email Button --->
<div style="background: ##fff3e0; border: 2px solid ##ff9800; padding: 20px; margin: 20px 0; border-radius: 5px; text-align: center;">
<h3 style="margin-top: 0;">Ready to Send Email</h3>
<p>Click the button below to send the order confirmation email to the customer.</p>
<a href="?send=true" style="padding: 15px 40px; background: ##4caf50; color: white; text-decoration: none; border-radius: 5px; display: inline-block; font-size: 16px; font-weight: bold;">
📧 Send Order Confirmation Email
</a>
</div>
</cfif>
<!--- Email Preview --->
<h3>📧 Email Preview</h3>
<div style="background: ##f5f5f5; padding: 20px; border-radius: 5px;">
<p style="color: ##666; margin-bottom: 15px;">This is how the email will appear to the customer:</p>
<!--- Email Preview Container --->
<div style="max-width: 600px; margin: 0 auto; background: white; border: 2px solid ##ddd; box-shadow: 0 2px 5px rgba(0,0,0,0.1);">
<div style="background: ##4caf50; color: white; padding: 30px; text-align: center;">
<h1 style="margin: 0;">✓ Order Confirmed!</h1>
<p style="margin: 10px 0 0 0;">Thank you for your purchase</p>
</div>
<div style="padding: 30px;">
<cfoutput>
<p>Hi #order.customerName#,</p>
<p>Your order has been confirmed and will be shipped soon.</p>
<div style="background: ##e3f2fd; padding: 15px; margin: 20px 0; border-radius: 3px;">
<p style="margin: 0;"><strong>Order Number:</strong> #order.orderID#</p>
<p style="margin: 5px 0 0 0;"><strong>Order Date:</strong> #dateFormat(order.orderDate, "mmmm d, yyyy")#</p>
</div>
<h3>Order Details</h3>
<table style="width: 100%; border-collapse: collapse;">
<thead>
<tr style="background: ##f5f5f5;">
<th style="padding: 10px; text-align: left; border-bottom: 2px solid ##ddd;">Item</th>
<th style="padding: 10px; text-align: center; border-bottom: 2px solid ##ddd;">Qty</th>
<th style="padding: 10px; text-align: right; border-bottom: 2px solid ##ddd;">Price</th>
<th style="padding: 10px; text-align: right; border-bottom: 2px solid ##ddd;">Total</th>
</tr>
</thead>
<tbody>
<cfloop array="#order.items#" index="item">
<tr>
<td style="padding: 10px; border-bottom: 1px solid ##eee;">#item.name#</td>
<td style="padding: 10px; text-align: center; border-bottom: 1px solid ##eee;">#item.quantity#</td>
<td style="padding: 10px; text-align: right; border-bottom: 1px solid ##eee;">$#numberFormat(item.unitPrice, "0.00")#</td>
<td style="padding: 10px; text-align: right; border-bottom: 1px solid ##eee;">$#numberFormat(item.total, "0.00")#</td>
</tr>
</cfloop>
</tbody>
<tfoot>
<tr>
<td colspan="3" style="padding: 10px; text-align: right;">Subtotal:</td>
<td style="padding: 10px; text-align: right;">$#numberFormat(order.subtotal, "0.00")#</td>
</tr>
<tr>
<td colspan="3" style="padding: 10px; text-align: right;">Tax:</td>
<td style="padding: 10px; text-align: right;">$#numberFormat(order.tax, "0.00")#</td>
</tr>
<tr>
<td colspan="3" style="padding: 10px; text-align: right;">Shipping:</td>
<td style="padding: 10px; text-align: right;">$#numberFormat(order.shipping, "0.00")#</td>
</tr>
<tr style="background: ##f5f5f5; font-weight: bold; font-size: 16px;">
<td colspan="3" style="padding: 15px; text-align: right;">TOTAL:</td>
<td style="padding: 15px; text-align: right; color: ##4caf50;">$#numberFormat(order.total, "0.00")#</td>
</tr>
</tfoot>
</table>
<h3>Shipping Information</h3>
<p><strong>Delivery Address:</strong><br>#order.shippingAddress#</p>
<p><strong>Tracking Number:</strong> #order.trackingNumber#</p>
<h3>Payment Method</h3>
<p>#order.paymentMethod#</p>
<div style="text-align: center; margin: 30px 0;">
<a href="https://www.mycompany.com/track?order=#order.orderID#" style="display: inline-block; padding: 15px 30px; background: ##2196f3; color: white; text-decoration: none; border-radius: 5px;">
Track Your Order
</a>
</div>
<p>Questions? Contact us at support@mycompany.com</p>
</cfoutput>
</div>
</div>
</div>
<div style="background: ##e3f2fd; border-left: 4px solid ##2196f3; padding: 15px; margin: 20px 0;">
<h4>💡 Order Confirmation Best Practices:</h4>
<ul>
<li><strong>Immediate Send:</strong> Send confirmation immediately after order placement</li>
<li><strong>Complete Details:</strong> Include all order items, prices, and totals</li>
<li><strong>Tracking Info:</strong> Provide tracking numbers when available</li>
<li><strong>PDF Attachment:</strong> Attach PDF invoice using cfmailparam</li>
<li><strong>Payment Security:</strong> Show only last 4 digits of payment method</li>
<li><strong>Clear Layout:</strong> Use tables for itemized lists</li>
<li><strong>Action Links:</strong> Include track order and view order buttons</li>
<li><strong>Contact Info:</strong> Provide customer service contact details</li>
</ul>
</div>