Skip to main content

Send an Order Confirmation Email

Send an order confirmation when a customer completes a purchase. The message is transactional, sent once per order, and personalized with line items, totals, shipping address, and tracking link.

Who this is for​

Developers integrating Mailtarget with an ecommerce backend (Shopify, WooCommerce, custom platform).

The Mailtarget surface​

ComponentUsed for
Transmission APIThe send
TemplatesReusable order-confirmation template with substitution data
Sending DomainsVerified from domain
WebhooksDelivery, bounce, customer complaints

Order confirmations are transactional. Do not put them through Email Marketing campaigns; the lifecycle and recipient model differ.

Execution​

Step 1: Build the template​

In the dashboard, create a template:

Subject: Order #{{order_id}} confirmed
Body:
Hi {{first_name|"there"}},

Thanks for your order. Receipt below.

Order #{{order_id}}
Items: {{items_summary}}
Total: {{total_amount}}
Ship date: {{ship_date}}

Track your shipment: {{tracking_url}}

Save and note the templateId.

Step 2: Send on order completion​

In your application, on order-confirmed event:

const res = await fetch("https://transmission.mailtarget.co/v1/layang/transmissions", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.MAILTARGET_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
subject: `Order #${order.id} confirmed`,
from: { email: "orders@your-domain.com", name: "Your Store" },
to: [{ email: order.customer.email, name: order.customer.name }],
templateId: "tmpl_order_confirmation_v3",
substitutionData: {
order_id: order.id,
first_name: order.customer.firstName,
items_summary: order.items.map(i => `${i.qty}x ${i.name}`).join(", "),
total_amount: order.totalFormatted,
ship_date: order.estimatedShipDate,
tracking_url: order.tracking.url,
},
metadata: {
order_id: order.id,
customer_id: order.customer.id,
channel: "ecommerce",
},
}),
});

const { transmissionId } = await res.json();
await db.orders.update(order.id, { confirmation_send_id: transmissionId });

Persist transmissionId against the order. Wire webhook handlers to flip the order's email-confirmation state on delivery, bounce, or complaint.

Common mistakes​

SymptomCauseFix
Customer reports duplicate order emailOrder-completed event fired twiceAdd idempotency key on the order; check confirmation_send_id before sending
Total amount renders as {{total_amount}} literallySubstitution field name mismatchMatch the template tag exactly
Customer never receives emailHard bounce on customer emailCheck bounce webhook; fall back to in-app notification or SMS
Sent to spamOrder-confirmation from domain shared with marketingUse dedicated subdomain like orders.your-domain.com

Outcome to track​

  • Delivery rate above 98 percent.
  • Open rate typically above 50 percent (transactional norm).
  • Reply rate above 0 (some customers reply with delivery questions; flag the sender to monitor replies).
  • Complaint rate below 0.1 percent. Higher means customers do not recognize the sender.